import sys input = sys.stdin.readline from collections import deque N=input().strip() A=list(map(int,input().split())) USE=[0]*1000001 ANS=0 Q=deque() for a in A: if USE[a]==1: while USE[a]==1: x=Q.popleft() USE[x]-=1 USE[a]=1 Q.append(a) ANS=max(ANS,len(Q)) print(ANS)