#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#include<vector>
int main() {
// your code goes here
vector<int>arr={1,2};
int n=arr.size();
int k=4;
int count=0,sum=0,i=0,j=0;
int d=0;
unordered_map<int,int>mp;
while(i<n && j<n)
{
mp[arr[j]]++;
d=mp.size();
while(d>k)
{
mp[arr[i]]--;
if(mp[arr[i]]==0)
{
mp.erase(arr[i]);
}
d=mp.size();
i++;
}
count+=(j-i+1);
j++;
}
cout<<count;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KI2luY2x1ZGU8dmVjdG9yPgoKaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCgl2ZWN0b3I8aW50PmFycj17MSwyfTsKCWludCBuPWFyci5zaXplKCk7CglpbnQgaz00OwoJaW50IGNvdW50PTAsc3VtPTAsaT0wLGo9MDsKICAgIGludCBkPTA7CiAgICB1bm9yZGVyZWRfbWFwPGludCxpbnQ+bXA7CiAgICB3aGlsZShpPG4gJiYgajxuKQogICAgIHsKICAgICAJbXBbYXJyW2pdXSsrOwogICAgIAlkPW1wLnNpemUoKTsKICAgICAJd2hpbGUoZD5rKQogICAgIAkgewogICAgIAkgCW1wW2FycltpXV0tLTsKICAgICAJIAlpZihtcFthcnJbaV1dPT0wKQogICAgIAkgCSB7CiAgICAgCSAJIAltcC5lcmFzZShhcnJbaV0pOwogICAgIAkgCSB9CiAgICAgCSAJZD1tcC5zaXplKCk7CiAgICAgCSAJaSsrOwogICAgIAkgfQogICAgIAkgY291bnQrPShqLWkrMSk7CiAgICAgCSBqKys7CiAgICAgfQogICAgIGNvdXQ8PGNvdW50OwoJIAoJcmV0dXJuIDA7Cn0=