#include <bits/stdc++.h>
using namespace std;
int main()
{
int n; cin >> n;
vector<int>buff(n);
for (int i = 0; i < n; ++i) cin >> buff[i];
int ans = 0, len = 0;
//最简单的空间换时间
map<int, int>count;
for (int i = 0, j = 0; i < n; ++i) {
count[buff[i]]++;
len++;
while(count[buff[i]] > 1) {
count[buff[j++]]--;
len --;
}
ans = max(len, ans);
}
cout << ans;
return 0;
}