#include using namespace std; int main() { int N; cin >> N; vector A(N); for (int i = 0; i < N; i++) cin >> A.at(i); set SE; int mx = 0; for (int l = 0, r = 0; r < N; r++) { if (SE.count(A.at(r))) { while (A.at(l) != A.at(r)) SE.erase(A.at(l++)); SE.erase(A.at(l++)); } SE.insert(A.at(r)); mx = max(mx, r - l + 1); } cout << mx << "\n"; }