#include #include #include using namespace std; int main(){ int n;cin>>n; set A; queue B; int ans = 0; for(int i = 0; n > i; i++){ int x;cin>>x; if(A.count(x)){ while(B.front() != x){ A.erase(B.front()); B.pop(); } B.pop(); } B.push(x); A.insert(x); ans = max(ans,(int)B.size()); } cout << ans << endl; }