import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.to!(int[]); } int calc(int[] xs) { bool[int] used = [xs[0]: true]; int[] q = [xs[0]]; int ans = 1; foreach (x; xs) { while (x in used) { used.remove(q[0]); q = q[1..$]; } used[x] = true; q ~= x; ans = max(ans, cast(int)q.length); } return ans; } void main() { readint; auto xs = readints; auto ans = calc(xs); writeln(ans); }