N = int(input()) A = list(map(int, input().split())) S = set() r = 0 ans = 0 for l in range(N): while r < N and A[r] not in S: S.add(A[r]) r += 1 if ans < r-l: ans = r-l if l == r: r += 1 else: S.remove(A[l]) print(ans)