#if !__INCLUDE_LEVEL__ #include __FILE__ int main() { ll n; in(n); vl A(n); in(A); ll l, r; l = r = 0; ll ans = 1; vb used(*max_element(ALL(A)) + 1, false); used[A[l]] = true; while (r < n - 1) { // de(l, r); if (!used[A[r + 1]]) { ++r; used[A[r]] = true; } else { used[A[l]] = false; ++l; } ans = max(ans, r - l + 1); } print(ans); return 0; } #else #include #include using namespace std; // clang-format off #define REP(i, n) for(ll i = 0; i < ll(n); i++) // [0, n): 0, 1,... ,n-1 #define rep(i, l, r) for(ll i = l; i < ll(r); i++) // [l, r): l, l+1,... ,r-1 #define rrep(i, r, l) for(ll i = r; i >= ll(l); i--) // [l, r]: r, r-1,... ,l #define ALL(v) (v).begin(), (v).end() #define QQQLX_OVERLOAD(e1, e2, e3, NAME, ...) NAME #define QQQlx1(x, BODY) [&](const auto &x) { return BODY; } #define QQQlx2(x, y, BODY) [&](const auto &x, const auto &y) { return BODY; } #define lx(...) QQQLX_OVERLOAD(__VA_ARGS__, QQQlx2, QQQlx1)(__VA_ARGS__) using ll = long long;using pll = pair;using vl = vector;using vvl = vector>;using vb=vector; istream& operator>>(istream& is, vl& vec) {assert(vec.size()>0);for(auto& e: vec)is>>e; return (is);} constexpr ll INF = 1e18;constexpr int LIMIT=1e5+1; struct IOSetup {IOSetup() {cin.tie(nullptr);ios_base::sync_with_stdio(false);cout << fixed << setprecision(20);}} iosetup; bool inside(ll x, ll y, ll h, ll w) {return 0 <= x && x < h && 0 <= y && y < w;}; vector dr = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; #ifdef _DEBUG #include "debug3.cpp" template void show_arr2D(const vector> &arr){REP(i,arr.size()){REP(j,arr[i].size())if(arr[i][j]<100)printf("%2lld ",arr[i][j]);else{cout << "bg" << " ";}cout << endl;}} #else #define de(...) {} #endif inline void in(void) { return; }template void in(First &first, Rest &...rest) {cin >> first;in(rest...);return;}void print() { cout << endl;}template void print(vector &vec) { for (auto& a : vec) {cout << a;if (&a != &vec.back()) cout << " "; } cout << endl;}template void print(vector> &df) { for (auto& vec : df) {print(vec); }}template void print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward(tail)...);} #endif