#include<iostream>#include<cmath>usingnamespace std;constint N =100010, T =320;int n, a[N];int pos[N], L[T], R[T];bool mark[T];int color[T];voidinitialize(){int t =sqrt(n);for(int i =1; i <= t;++ i){
L[i]= R[i -1]+1;
R[i]= i * t;}if(R[t]< n){++ t;
L[t]= R[t -1]+1;
R[t]= n;}for(int i =1; i <= t;++ i)for(int j = L[i]; j <= R[i];++ j)
pos[j]= i;}voidupdate(int k){if(mark[k]==false)return;
mark[k]=false;for(int i = L[k]; i <= R[k];++ i)
a[i]= color[k];}voidmodify(int l,int r,int val){// a[l ~ r] = valint x = pos[l], y = pos[r];if(x == y){update(x);for(int i = l; i <= r;++ i) a[i]= val;}else{for(int i = x +1; i <= y -1;++ i){
mark[i]=true;
color[i]= val;}update(x);for(int i = l; i <= R[x];++ i) a[i]= val;update(y);for(int i = L[y]; i <= r;++ i) a[i]= val;}}intquery(int l,int r,int val){int x = pos[l], y = pos[r];int res =0;if(x == y){update(x);for(int i = l; i <= r;++ i)if(a[i]== val)++ res;}else{for(int i = x +1; i <= y -1;++ i){if(mark[i]==true){
res +=(color[i]== val ? R[i]- L[i]+1:0);}else{for(int j = L[i]; j <= R[i];++ j)if(a[j]== val)++ res;}}update(x);for(int i = l; i <= R[x];++ i)if(a[i]== val)++ res;update(y);for(int i = L[y]; i <= r;++ i)if(a[i]== val)++ res;}return res;}intmain(){
cin >> n;for(int i =1; i <= n;++ i) cin >> a[i];initialize();for(int i =1, l, r, c; i <= n;++ i){
cin >> l >> r >> c;
cout <<query(l, r, c)<< endl;modify(l, r, c);}return0;}