import strutils, sequtils, algorithm, math var n = readLine(stdin).parseInt() a_seq = readLine(stdin).split(' ').map(parseInt) inchworm = newSeq[int](100_000_002) right, tmp_a : int left, max_len = 0 for right in countup(1, n): tmp_a = a_seq[right - 1] if inchworm[tmp_a] > 0: left = inchworm[tmp_a] max_len = max(max_len, right - left) inchworm[tmp_a] = right echo(max_len)