#include <iostream>
#include <vector>
using namespace std;
vector<int> nums;
int res = 0;
int s[100010];
void solve(vector<int>& nums) {
for (int i = 0, j = 0; i < nums.size(); i++) {
s[nums[i]]++;
while (s[nums[i]] > 1) {
s[nums[j]]--;
j++;
}
res = max(res, i - j + 1);
}
}
int main()
{
int n;
cin >> n;
while (n -- ) {
int x;
cin >> x;
nums.push_back(x);
}
solve(nums);
cout << res << endl;
return 0;
}