#include<iostream>
#include<algorithm>
using namespace std;
const int N = 100010, MAX = 100010;
int a[N], cnt[MAX];
int main()
{
int n, res = 0, i = 0, j = 0;
cin >> n;
for (int i = 0; i < n ; i++) scanf("%d", &a[i]);
while (j < n)
{
cnt[a[j]]++;
while (cnt[a[j]] > 1) cnt[a[i++]]--;
res = max(res, j - i + 1);
j++;
}
cout << res << endl;
}