/*
Author: EnderDeer
Online Judge: Luogu
*/
#include<bits/stdc++.h>
#define int long long
#define mem(x) memset(x,0,sizeof(x))
using namespace std;
int read(){
int s = 0,w = 1;
char ch = getchar();
while(ch < '0' || ch > '9'){if(ch == '-')w = -1;ch = getchar();}
while(ch >= '0' && ch <= '9')s = s * 10 + ch - '0',ch = getchar();
return s * w;
}
int n;
int a[100010];
int block,len;
int lazy[100010];
int num[100010];
int l[100010],r[100010];
bool bk[100010];
int tag[100010];
void update(int x,int y,int w){
int posl = num[x];
int posr = num[y];
if(posl == posr){
bk[posl] = false;
for(int i = x;i <= y;i ++){
a[i] = w;
}
return ;
}
for(int i = x;i <= r[posl];i ++)a[i] = w;
bk[posl] = false;
for(int i = posl + 1;i <= posr - 1;i ++){
bk[i] = true;
tag[i] = w;
}
for(int i = l[posr];i <= y;i ++)a[i] = w;
bk[posr] = false;
}
int query(int x,int y,int w){
int posl = num[x];
int posr = num[y];
int ans = 0;
if(posl == posr){
for(int i = x;i <= y;i ++){
if(a[i] == w)ans ++;
}
return ans;
}
for(int i = x;i <= r[posl];i ++){
if(a[i] == w)ans ++;
}
for(int i = posl + 1;i <= posr - 1;i ++){
if(!bk[i]){
for(int j = l[i];j <= r[i];j ++){
if(a[i] == w)ans ++;
}
}
else {
if(tag[i] == w)ans += block;
}
}
for(int i = l[posr];i <= y;i ++){
if(a[i] == w)ans ++;
}
return ans;
}
signed main(){
cin>>n;
block = sqrt(n);
len = ceil(n * 1.0 / block);
for(int i = 1;i <= n;i ++)a[i] = read();
for(int i = 1;i <= n;i ++){
num[i] = (i - 1) / block + 1;
}
for(int i = 1;i <= len;i ++){
l[i] = (i - 1) * block + 1;
r[i] = i * block;
}
r[len] = n;
for(int i = 1;i <= n;i ++){
int x,y,w;
x = read(),y = read(),w = read();
printf("%lld\n",query(x,y,w));
update(x,y,w);
}
return 0;
}