#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; typedef vector VI; typedef pair PI; const double EPS=1e-9; const int N = 100010; int a[N]; int main(void){ int n; cin >> n; REP(i, 0, n) { cin >> a[i]; } int q = 1; int m = 0; set acc; REP(p, 0, n) { for (; q < n && acc.count(a[q]) == 0; ++q) { acc.insert(a[q]); } m = max(m, q - p); acc.erase(a[p]); } cout << m << endl; }