import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int n; int[] a; scan(n); a = readln.split.to!(int[]); auto b = new bool[](a.reduce!max + 1); int ans; for (int l,r; r < n; r++) { if (b[a[r]]) { for (; b[a[r]]; l++) { b[a[l]] = 0; } } debug { writefln("(l, r) = (%s, %s)", l, r); } ans = r - l + 1; b[a[r]] = 1; } writeln(ans); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primitives; auto line = readln().splitter(); foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFront(); } assert(line.empty); } void fillAll(R, T)(ref R arr, T value) { static if (is(typeof(arr[] = value))) { arr[] = value; } else { foreach (ref e; arr) { fillAll(e, value); } } }