from collections import defaultdict n = int(input()) a = list(map(int, input().split())) s1, s2 = set([a[0]]), set(a[1:]) t1, t2 = defaultdict(int), defaultdict(int) t1[a[0]] += 1 for i in range(1, n): t2[a[i]] += 1 ans = [] for i in range(1, n): if len(s1) == i and len(s2) == (n-i): ans.append(i) if i == n-1: break t2[a[i]] -= 1 t1[a[i]] += 1 if t2[a[i]] <= 0: s2.remove(a[i]) s1.add(a[i]) print(len(ans)) print(*ans)