#include <iostream>
using namespace std;
const int N=100010;
int n;
int a[N],s[N]={0};
int main()
{
cin >> n;
for(int i=0;i<n;i++) cin >>a[i];
int res=0;
for(int i=0,j=0;i<n;i++){
s[a[i]]++;
while(s[a[i]]>1){
s[a[j]]--;
j++;
}
res=max(res,i-j+1);
}
cout<<res<<endl;
return 0;
}
04-16
314
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)