/// Fuck Them, Fuck Me, and Fuck You
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define pb push_back
#define F first
#define S second
#define f(i,a,b) for(int i = a; i < b; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 3e5 + 5, LG = 19, MOD = 1e9 + 7;
ll ans[1000006];
ll ans2[1000006];
int main(){
#ifdef ONLINE_JUDGE
ios_base::sync_with_stdio(0);
cin.tie(0);
#endif // ONLINE_JUDGE
int n;
cin >> n;
int ans = 1;
map<int,int> mp;
f(i,0,n){
int x;
cin >> x;
if(mp.count(x) == 0)
mp[x] = i;
else
ans = max(ans, i - mp[x] + 1);
}
cout << ans << '\n';
return 0;
}
Copy