#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } N++; A.emplace_back(*max_element(A.begin(), A.end()) + 1); vector B(*max_element(A.begin(), A.end()) + 2, false); int res = 0, r = 0; for (int l = 0; l < N; l++) { while (r < N && !B[A[r]]) { B[A[r]] = true; r++; } if (!(r < N)) r--; res = max(res, r - l); B[A[l]] = false; } cout << res << '\n'; return 0; }