n = int(input()) a = list(map(int, input().split())) l = 0 r = 0 ans = 0 st = set() while l < n: if r <= l: r = l while r < n and a[r] not in st: st.add(a[r]) ans = max(ans, len(st)) r += 1 st.remove(a[l]) l = r print(ans)