#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
int n;
cin>>n;
if(n>4){
int left=0;
int right=3;
vector<int>s;
int temp;
while(cin>>temp){
s.push_back(temp);
}
int count=0;
while(right<n){
map<int,int>k;
for(int i=left;i<=right;i++){
k[s[i]]++;
//cout<<s[i]<<" ";
}
//cout<<endl;
for(auto it:k){
if(it.second==3){
left+=3;
right+=3;
count++;
}
}
left++;
right++;
}
cout<<count;
}
}
// 64 位输出请用 printf("%lld")
左右指针的基本操作

京公网安备 11010502036488号