N = int(input()) A = list(map(int, input().split())) # 全部異なる文字のとき if len(set(A))==N: print(N-1) print(" ".join(map(str,range(1,N)))) exit() # 左側に重複要素が存在しないiの最小値をもとめる ng = -1 ok = N while True: left = (ok + ng)//2 if len(set(A[:left]))!=left: ok = left else: ng = left if ng==ok-1: break left = ng # 右側に重複要素が存在しないiの最大値をもとめる ng = -1 ok = N while True: right = (ok + ng)//2 if len(set(A[right:]))!=N-right: ng = right else: ok = right if ng==ok-1: break right = ok ans = range(right, left+1) print(len(ans)) print(" ".join(map(str,ans))) "🐬"