from collections import defaultdict n = int(input()) a = list(map(int, input().split())) m = 0 M = n d = defaultdict(list) for i in range(n): d[a[i]].append(i) for i, j in d.items(): if len(j) > 2: exit(print(0)) if len(j) == 2: m = max(m, j[0]) M = min(M, j[1]) ans = list(range(m + 1, M + 1)) print(len(ans)) print(*ans)