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 = many_int() deq = deque([]) sets = set([]) maxs = 0 for a in A: if a in sets: maxs = max(len(deq),maxs) while deq: temp = deq.popleft() sets.remove(temp) if temp==a: break else: sets.add(a) deq.append(a) print( max(len(deq),maxs))