#include using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i) #define all(a) (a).begin(), (a).end() int main() { cin.tie(nullptr); int N; cin >> N; vector A(N); rep(i, 0, N) cin >> A[i]; set s; int ans = 0; int l = 0, r = 0; while (true) { if (l == N) break; if (r <= N - 1 && !s.count(A[r])) { s.insert(A[r]); r++; } else { s.erase(A[l]); l++; } ans = max(ans, r - l); } cout << ans << '\n'; }