#include <bits/stdc++.h>
#include <boost/format.hpp>
using namespace std;

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename
#define endl '\n'
using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> istream& operator >>(istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { for (auto& _e : _v) fill(_e, _t); }
TPL<TNM T> void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
TPL<TNM T> void hash_combine(size_t& seed, T const& v) { std::hash<T> __h; seed ^= __h(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	int N;
	cin >> N;
	vec<ll> A(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	ll res = 0;

	for (int left = 0; left < N; ++left) {
		set<int> s;
		s.insert(A[left]);
		int right = left + 1;
		while (right < N && s.count(A[right]) == 0) {
			s.insert(A[right]);
			++right;
		}
		res = max(res, (ll)(right - left));
	}

	cout << res << endl;
	return 0;
}