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[]); } ulong calc(int[] xs) { bool[int] used; used[xs[0]] = true; int[] q = [xs[0]]; ulong ans = 1; foreach (x; xs) { while (x in used) { used.remove(q[0]); q = q[1..$]; } assert(x !in used); used[x] = true; q ~= x; ans = max(ans, q.length); } return ans; } void main() { readint; auto xs = readints; auto ans = calc(xs); writeln(ans); }