N = int(input()) A = list(map(int, input().split())) memo = set() l = 0 ans = 0 for r, a in enumerate(A): while l < r and a in memo: memo -= {A[l]} l += 1 memo.add(a) ans = max(ans, len(memo)) print(ans)