#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int n;
cin >> n;
map<int, vector<int>> mp;
for (int i = 0, x; i < n; ++i) {
cin >> x;
mp[x].push_back(i);
}
int ans = 0;
for (auto &i : mp) ans = max(ans, i.second.back() - i.second.front() + 1);
cout << ans << '\n';
return 0;
}