#include <iostream>
#include <iomanip>
#include<iterator> // for iterators
#include<vector> // for vectors
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <unordered_map>
using namespace std;
int main()
{
ios_base :: sync_with_stdio (false);
cin.tie (NULL);
cout.tie (NULL);
int n; scanf("%d", &n);
vector<int> v;
for (int i = 0; i < n; ++i) {
int temp;
scanf("%d", &temp);
v.emplace_back(temp);
}
int max = 0, temp;
for (int i = 0; i < n; ++i)
{
for (int j = i; j < n; ++j)
{
if (v[i] == v[j])
temp = j - i;
if (temp > max)
max = temp;
}
}
printf("%d\n", max+1);
return 0;
}
Copy