#include "unique.h"
#include<iostream>
#include<vector>
#define MAXN 100000
using namespace std;
vector <int> a;
void init (vector <int> a) {
    ::a=a;
}
int cnt[MAXN+1];
//int count1=0;
//long long int sum=0;
vector <int> queries (vector <pair <int, int>> q) {
    vector <int> anss;
    anss.reserve(q.size());
    for (auto [l, r] : q) {
        //count1++;
        //sum+=(r-l+1);
        int ans=0;
        for (int i=l; i<=r; i++) {
            if (cnt[a[i]]==0) ans++;
            if (cnt[a[i]]==1) ans--;
            cnt[a[i]]++;
        }
        for (int i=l; i<=r; i++) {
            cnt[a[i]]=0;
        }
        anss.push_back(ans);
    }
    //if (count1==a.size()) cerr << sum << endl ;
    return anss;
}
void update (int i, int v) {
    //count1++;
    a[i]=v;
}
