def one_str(): return input() def many_int(): return list(map(int, input().split())) from collections import deque input_count = 0 N = int(input()) A=[] if N!=0: A = many_int() deq = deque([]) sets = set([]) maxs = 0 for a in A: if a in sets: maxs = max(len(deq),maxs) deq.append(a) while deq: temp = deq.popleft() if temp==a: break sets.remove(temp) else: sets.add(a) deq.append(a) print( max(len(deq),maxs))