AtCoder Beginner Contest 134 - Preparing Boxes

There are N empty boxes arranged in a row from left to right.
The integer i is written on the i-th box from the left (1 \leq i \leq N).
For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.
We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:
 - For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.
Does there exist a good set of choices? If the answer is yes, find one good set of choices.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq N \leq 2 \times 10^5
 - a_i is 0 or 1.

-----Input-----
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N

-----Output-----
If a good set of choices does not exist, print -1.
If a good set of choices exists, print one such set of choices in the following format:
M
b_1 b_2 ... b_M

where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order.

-----Sample Input-----
3
1 0 0

-----Sample Output-----
1
1

Consider putting a ball only in the box with 1 written on it.
 - There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.
 - There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.
 - There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.
Thus, the condition is satisfied, so this set of choices is good.

Difficulty: MEDIUM

Starter code:

Solutions:
N = int(input())
A = list(map(int, input().split()))
A = [0] + A
for i in range(N // 2, 0, -1):
	A[i] = sum(A[i::i]) % 2
ans = [i for i in range(N + 1) if A[i]]
print(len(ans))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n, 0, -1):
	if sum(b[i - 1::i]) % 2 == a[i - 1]:
		continue
	else:
		b[i - 1] = 1
b_index = [i + 1 for i in range(n) if b[i] == 1]
print(sum(b))
print(*b_index)


N = int(input())
boxes = [0] * (N + 1)
ans = tuple((n for (n, digit) in reversed(tuple(enumerate(map(int, input().split()), 1))) if sum((d for d in boxes[n::n])) & 1 != digit and (boxes.__setitem__(n, 1) or 1)))
print('%d\n' % len(ans), *ans)


import sys
input = sys.stdin.readline
N = int(input())
a = [0] + list(map(int, input().split()))
for i in range(N, 0, -1):
	a[i] = sum(a[i::i]) % 2
print(sum(a))
del a[0]
for (i, v) in enumerate(a):
	if v == 1:
		print(i + 1, end=' ')


N = int(input())
A = list(map(int, input().split()))
boxes = [0] * N
for i in range(N)[::-1]:
	s = sum(boxes[i::i + 1])
	if s % 2 != A[i]:
		boxes[i] = 1
M = sum(boxes)
print(M)
if M != 0:
	print(*[i + 1 for (i, j) in enumerate(boxes) if j == 1])


import math
import queue
import bisect
from collections import deque, defaultdict
import heapq as hpq
from sys import stdin, setrecursionlimit
ipt = stdin.readline
setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

def main():
	n = int(ipt())
	a = [int(i) for i in ipt().split()]
	p2 = [0] * (n + 1)
	for i in range(n, 0, -1):
		sm = 0
		for j in range(i, n + 1, i):
			sm += p2[j]
		p2[i] = (a[i - 1] - sm) % 2
	sm = sum(p2)
	print(sm)
	ans = []
	for (i, pi) in enumerate(p2):
		if pi:
			ans.append(str(i))
	print(' '.join(ans))
	return None

def __starting_point():
	main()
__starting_point()


n = int(input())
A = list(map(int, input().split()))
ans = set()
for i in range(n - 1, -1, -1):
	for j in range(i + 1, n + 1, i + 1):
		if j in ans:
			A[i] += 1
	if A[i] % 2:
		ans.add(i + 1)
print(len(ans))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
for i in range(n - 1, -1, -1):
	tmp = 0
	for j in range(2 * (i + 1) - 1, n, i + 1):
		tmp ^= b[j]
	b[i] = a[i] ^ tmp
ans = [i + 1 for i in range(n) if b[i]]
print(len(ans))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
ans = [0] * (n + 1)
for i in range(n, 0, -1):
	temp = 0
	for j in range(i, n + 1, i):
		temp += ans[j]
	if a[i - 1] != temp % 2:
		ans[i] = 1
print(sum(ans))
for i in range(n + 1):
	if ans[i] == 1:
		print(i, end=' ')


N = int(input())
a = list(map(int, input().split()))
M = 0
b = [0] * N
B = []
for i in range(N, 0, -1):
	wa = sum(b[i - 1::i])
	if wa % 2 != a[i - 1]:
		M += 1
		b[i - 1] = 1
		B.append(i)
print(M)
if M != 0:
	print(*B)


data = int(input())
array = list(map(int, input().split()))
result = []
box = [0] * data
for i in reversed(range(1, data + 1)):
	asum = sum(box[i - 1::i])
	if asum % 2 + array[i - 1] == 1:
		box[i - 1] = 1
		result.append(i)
print(len(result))
print(*result)


N = int(input())
a = list(map(int, input().split()))
t = [0] * N
for i in range(N - 1, -1, -1):
	t[i] = sum(t[2 * (i + 1) - 1::i + 1]) % 2 ^ a[i]
print(sum(t))
print(*[i + 1 for i in range(N) if t[i] == 1])


n = int(input())
a = [int(i) for i in input().split()]
a = [0] + a
for i in range(n, 0, -1):
	a[i] = sum(a[i::i]) % 2
ans = []
for i in range(len(a)):
	if a[i] == 1:
		ans.append(i)
print(len(ans))
if len(ans) != 0:
	print(' '.join(map(str, ans)))


n = int(input())
a = [int(x) for x in input().split()]
b = [0] * n
c = []
for i in range(n):
	if sum(b[n - i - 1:n:n - i]) % 2 != a[n - i - 1]:
		b[n - i - 1] += 1
		c.append(n - i)
print(len(c))
print(' '.join(map(str, c[::-1])))


n = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(n)]
B[n // 2:] = A[n // 2:]
for i in range(n // 2, 0, -1):
	B[i - 1] = sum(B[i * 2 - 1::i]) % 2 != A[i - 1]
print(sum(B))
for (i, j) in enumerate(B):
	if j == 1:
		print(i + 1)


n = int(input())
A = list(map(int, input().split()))
num = [i for i in range(n)]
B = [0] * n
C = []
ans = 0
for i in range(n - 1, -1, -1):
	ms = sum(B[i::i + 1])
	if ms % 2 != A[i]:
		ans += 1
		C.append(i + 1)
		B[i] = 1
print(ans)
print(*C)


N = int(input())
binary = [int(s) for s in input().split()]
boxes = [0 for _ in range(N)]
ans = set()
for i in range(N - 1, -1, -1):
	if sum(boxes[i::i + 1]) % 2 != binary[i]:
		boxes[i] = 1
		ans.add(i + 1)
print(len(ans))
print(*ans)


(n, *a) = map(int, open(0).read().split())
b = [0] * -~n
for i in range(n, 0, -1):
	t = 0
	for j in range(i, n + 1, i):
		t += b[j]
	b[i] = (t + a[i - 1]) % 2
c = [i for (i, b) in enumerate(b) if b]
print(len(c), *c)


N = int(input())
A = list(map(int, input().split()))
L = A[:]
for i in range(N // 2, 0, -1):
	x = N // i
	s = sum([L[i * k - 1] for k in range(1, x + 1)]) % 2
	if L[i - 1] != s:
		L[i - 1] = s
print(sum(L))
L = [str(i + 1) for (i, c) in enumerate(L) if c == 1]
print(' '.join(L))


icase = 0
if icase == 0:
	n = int(input())
	a = [0] + list(map(int, input().split()))
elif icase == 3:
	f = open('C:\\Users\\nishi\\999atcoder\\ABCD040-151\\ABC134D\\testcase_12.in')
	ll = f.readline()
	n = int(ll)
	ll = f.readline()
	a = [0] + list(map(int, ll.split()))
	f.close()
b = [0] * (n + 1)
for i in range(n // 2 + 1, n + 1):
	b[i] = a[i]
for i in range(n // 2, 0, -1):
	i2 = i * 2
	asum = 0
	while i2 <= n:
		asum += b[i2]
		i2 += i
	b[i] = (asum + a[i]) % 2
print(sum(b))
for i in range(1, len(b)):
	if b[i] == 1:
		print(i, end=' ')
print(' ')


n = int(input())
a = [int(i) for i in input().split()]
cnt = [0] * n
for i in range(n, 0, -1):
	total = sum((cnt[i * k - 1] for k in range(1, n // i + 1)))
	if total % 2 != a[i - 1]:
		cnt[i - 1] = 1
b = [i + 1 for i in range(n) if cnt[i] > 0]
print(sum(cnt))
print(*b)


n = int(input())
l = list(map(int, input().split()))
for i in range(n, 0, -1):
	l[i - 1] = sum(l[i - 1::i]) % 2
print(sum(l))
print(*[i + 1 for i in range(n) if l[i]])


n = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (n + 1)
for i in reversed(range(1, n + 1)):
	if sum(b[i::i]) % 2 != a[i]:
		b[i] = 1
print(sum(b))
for (i, j) in enumerate(b):
	if j == 1:
		print(i, end=' ')


n = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(n, 0, -1):
	p = 0
	for t in range(i * 2, n + 1, i):
		p += b[t]
	b[i] = p % 2 ^ a[i]
print(sum(b))
print(' '.join(map(str, [i for i in range(1, n + 1) if b[i]])))


N = int(input())
A = [int(_) for _ in input().split()]
X = [0 for _ in range(N)]
ans = []
for i in range(N)[::-1]:
	v = 0
	for j in range(i, N, i + 1):
		v += X[j]
	if v % 2 != A[i]:
		X[i] = 1
		ans.append(i + 1)
print(len(ans))
for i in ans:
	print(i)


N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
ball = [0] * (N + 1)
M = 0
ans = []
for i in reversed(range(1, N + 1)):
	j = 2
	total = 0
	while i * j <= N:
		total += ball[i * j]
		j += 1
	if total % 2 != A[i]:
		ball[i] = 1
		M += 1
for i in range(1, N + 1):
	if ball[i] == 1:
		ans.append(i)
print(M)
print(*ans)


N = int(input())
A = ['*'] + list(map(int, input().split()))
B = ['*'] + list([0] * N)
for k in range(N, 0, -1):
	p = A[k]
	for i in range(2 * k, N + 1, k):
		p ^= B[i]
	B[k] = p
C = [k for k in range(1, N + 1) if B[k]]
print(len(C))
if C:
	print(' '.join(map(str, C)))


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
ans = []
for i in range(n)[::-1]:
	tmp = 0
	for j in range(n // (i + 1)):
		tmp += b[(i + 1) * (j + 1) - 1]
	if tmp % 2 != a[i]:
		b[i] += 1
		ans.append(i + 1)
print(sum(b))
print(*ans)


N = int(input())
a = list(map(int, input().split()))
A = [0] + a
B = [0] * (N + 1)
ans = []
for i in range(N, 0, -1):
	tmp = 0
	for j in range(i * 2, N + 1, i):
		tmp += B[j]
	if tmp % 2 != A[i]:
		B[i] = 1
		ans.append(i)
if len(ans) == 0:
	print(0)
else:
	print(len(ans))
	print(' '.join(map(str, ans)))


n = int(input())
a = list(map(int, input().split()))
b = a.copy()
for i in range(n // 2, 0, -1):
	if a[i - 1] != sum(b[i - 1::i]) % 2:
		b[i - 1] = 1 - a[i - 1]
print(sum(b))
print(*(i + 1 for (i, x) in enumerate(b) if x))


def main():
	import sys

	def input():
		return sys.stdin.readline().rstrip()
	n = int(input())
	a = [0] + list(map(int, input().split()))
	for i in range(n, 0, -1):
		k = 1
		flag = 0
		while i * k <= n:
			flag ^= a[i * k]
			k += 1
		if flag != a[i]:
			a[i] ^= 1
	ans = [i for i in range(n + 1) if a[i] == 1]
	if ans == []:
		print(0)
	else:
		print(len(ans))
		print(*ans)

def __starting_point():
	main()
__starting_point()


n = int(input())
a = list(map(int, input().split()))
box = [0] * n
ansli = []
ans = 0
for i in reversed(range(n)):
	if sum(box[i::i + 1]) % 2 != a[i]:
		box[i] = not box[i]
		ansli.append(str(i + 1))
		ans += 1
print(ans)
print(' '.join(ansli))


n = int(input())
a = [0] + list(map(int, input().split()))
for i in range(n // 2, 0, -1):
	a[i] = sum(a[i::i]) % 2
s = [i for (i, b) in enumerate(a) if b]
print(len(s))
print(*s)


n = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (n + 1)
for i in reversed(list(range(1, n + 1))):
	ans = 0
	for j in range(i, n + 1, i):
		ans += b[j]
	if ans % 2 == a[i]:
		b[i] = 0
	else:
		b[i] = 1
c_ = []
for (c, d) in enumerate(b):
	if d == 1:
		c_.append(str(c))
print(len(c_))
print(' '.join(c_))


import sys
input = sys.stdin.readline
N = int(input().rstrip('\n'))
As = [int(x) for x in input().rstrip('\n').split()]
res = [0] * N
for i in range(N, 0, -1):
	now = sum(res[i - 1::i]) % 2
	if now != As[i - 1]:
		res[i - 1] += 1
print(sum(res))
print(*[x + 1 for x in range(N) if res[x] > 0])


(n, *a) = map(int, open(0).read().split())
a = [0] + a
b = [0] * -~n
for i in range(n, 0, -1):
	s = sum((b[j] for j in range(i, n + 1, i)))
	if s % 2 != a[i]:
		b[i] = 1
print(sum(b))
print(*[i for (i, b) in enumerate(b) if b == 1])


n = int(input())
a = [int(i) for i in input().split()]
x = [0] * n
for i in range(n, 0, -1):
	(m, c) = (2, 0)
	while i * m <= n:
		c += x[i * m - 1]
		m += 1
	x[i - 1] = (a[i - 1] + c % 2) % 2
print(sum(x))
for i in range(n):
	if x[i]:
		print(i + 1)


n = int(input())
A = list(map(int, input().split()))
import numpy as np
B = [0 for _ in range(n)]
ans = []
for (i, a) in enumerate(A[::-1]):
	i = len(A) - i - 1
	B[i] = int(np.array(B[i::i + 1]).sum() % 2 != a)
	if B[i] == 1:
		ans.append(i + 1)
print(len(ans))
if len(ans) > 0:
	print(*ans)


import sys

def IN_I():
	return int(sys.stdin.readline().rstrip())

def IN_LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def IN_S():
	return sys.stdin.readline().rstrip()

def IN_LS():
	return list(sys.stdin.readline().rstrip().split())
N = IN_I()
a = [0] + IN_LI()
b = [0] * (N + 1)
ans = []
for i in range(N, 0, -1):
	tmp = 0
	for j in range(2 * i, N + 1, i):
		tmp += b[j]
	if tmp % 2 != a[i]:
		b[i] = 1
		ans.append(i)
if len(ans) == 0:
	print(0)
else:
	print(len(ans))
	print(' '.join(map(str, ans)))


N = int(input())
A = list(map(int, input().split()))
B = [0] * (N + 1)
ans = []
for n in range(N):
	i = N - n
	BB = B[::i]
	if sum(BB) % 2 != A[i - 1]:
		B[i] = 1
		ans.append(str(i))
print(len(ans))
print(' '.join(ans))


N = int(input())
A = list(map(int, input().split()))
B = [0] * (N + 1)
x = []
for n in range(N):
	if sum(B[::N - n]) % 2 != A[N - n - 1]:
		B[N - n] = 1
		x.append(str(N - n))
print(len(x), '\n', ' '.join(x))


N = int(input())
a = list(map(int, input().split()))
b = []
dp = [0] * (N + 1)
ans = 0
for i in range(N, 0, -1):
	p = 0
	for j in range(1, N // i + 1):
		p += dp[j * i]
	if p % 2 != a[i - 1]:
		dp[i] = 1
		ans += 1
		b.append(i)
b.sort()
print(ans)
print(*b)


N = int(input())
a = list(map(int, input().split()))
b = [0] * (N + 1)
for i in range(N, 0, -1):
	if sum(b[i::i]) % 2 != a[i - 1]:
		b[i] = 1
print(sum(b))
for (i, j) in enumerate(b):
	if j == 1:
		print(i)


n = int(input())
arr = list(map(int, input().split()))
count = 0
arr3 = [0] * n
arr5 = []
if list(set(arr)) == [0]:
	print(0)
	return
for j in range(n, 0, -1):
	cancer = 0
	pre = 0
	for k in range(j, n + 1, j):
		pre += arr3[k - 1]
	if pre % 2 != arr[j - 1]:
		count += 1
		arr5.append(j)
		arr3[j - 1] += 1
print(count)
for aa in arr5:
	print(aa)


import math
N = int(input())
a = [0] + list(map(int, input().split()))
for i in range(1, N + 1)[::-1]:
	a[i] = sum(a[i::i]) % 2
ans = [index for (index, v) in enumerate(a) if v == 1]
print(len(ans))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
m = 0
aa = [0] * n
b = []
for i in range(n - 1, -1, -1):
	t = sum(aa[i::i + 1]) % 2
	if t != a[i]:
		m += 1
		aa[i] += 1
		b.append(i + 1)
print(m)
print(*b)


N = int(input())
A = list(map(int, input().split()))
B = [0] * N
for (i, a) in list(enumerate(A))[::-1]:
	i += 1
	d = sum(B[i - 1::i])
	if a != d % 2:
		B[i - 1] = 1
print(sum(B))
for (i, b) in enumerate(B):
	if b != 0:
		print(i + 1)


N = int(input())
A = [0] + list(map(int, input().split()))
B = [0] * (N + 1)
for i in reversed(range(1, N + 1)):
	ball = 0
	base = i + 1
	for j in range(i, N + 1, i):
		ball += B[j]
	if ball % 2 != A[i]:
		B[i] = 1
print(sum(B))
print(*[i for (i, b) in enumerate(B) if b == 1], sep=' ')


N = int(input())
A = [int(i) for i in input().split()]
nums = []
memo = [0] * N
for i in range(N - 1, -1, -1):
	if A[i] != sum(memo[i::i + 1]) % 2:
		memo[i] = 1
		nums.append(i + 1)
print(sum(memo))
print(' '.join(map(str, nums)))


(n, *a) = map(int, open(0).read().split())
b = [0] * n
for i in range(1, n + 1)[::-1]:
	if not sum(b[i - 1::i]) % 2 == a[i - 1]:
		b[i - 1] = 1
print(sum(b))
print(*[i + 1 for (i, b_i) in enumerate(b) if b_i == 1])


n = int(input())
a = list(map(int, input().split()))
box = set([])
for i in range(n, 0, -1):
	cnt = 0
	for j in range(1, n // i + 1):
		if i * j in box:
			cnt += 1
	if cnt % 2 != a[i - 1]:
		box.add(i)
print(len(box))
print(*box)


import sys
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
for i in range(n, 0, -1):
	val = 0
	for j in range(i, n + 1, i):
		val += b[j - 1]
	if val % 2 != a[i - 1]:
		b[i - 1] += 1
num = sum(b)
if num == 0:
	print(0)
else:
	print(num)
	for i in range(n):
		if b[i] != 0:
			print(i + 1)


N = int(input())
a = [0] + list(map(int, input().split()))
b = []
for i in range(1, N + 1)[::-1]:
	s = sum((a[j] for j in range(i * 2, N + 1, i)))
	if s % 2 == 1:
		a[i] = 1 - a[i]
	if a[i]:
		b.append(i)
print(len(b))
if len(b) > 0:
	print(*b)


n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n - 1, -1, -1):
	x = sum(ans[i::i + 1]) % 2
	if x != a[i]:
		ans[i] = 1
print(sum(ans))
for i in range(n):
	if ans[i] == 1:
		print(str(i + 1) + ' ', end='')


n = int(input())
num = [0] + [int(i) for i in input().split()]
ans = []
for i in range(n, 0, -1):
	(cnt, j) = (0, 2)
	while i * j <= n:
		cnt += num[i * j]
		j += 1
	if cnt % 2 == num[i]:
		num[i] = 0
	else:
		num[i] = 1
		ans.append(i)
print(len(ans))
print(*ans)


N = int(input())
A = tuple(map(int, input().split()))
lst = [0] * (N + 1)
ans = set()
for i in range(N, 0, -1):
	tmp = (sum(lst[i::i]) % 2 + A[i - 1]) % 2
	if tmp:
		ans.add(i)
	lst[i] = tmp
print(len(ans))
print(*ans)


N = int(input())
a = [0] + list(map(int, input().split()))
b = [0 for _ in range(N + 1)]
for i in reversed(range(1, N + 1)):
	tmp = 0
	for j in range(i, N + 1, i):
		tmp += b[j]
	if tmp % 2 == a[i]:
		b[i] = 0
	else:
		b[i] = 1
ans = []
for (i, j) in enumerate(b):
	if j == 1:
		ans.append(i)
print(len(ans))
if len(ans):
	print(*ans)


N = int(input())
Alist = list(map(int, input().split()))
Answer = [0] * (N + 1)
M = 0
for i in range(1, len(Alist) + 1):
	A = Alist[-i]
	n = N + 1 - i
	if sum(Answer[n::n]) % 2 != A:
		Answer[-i] = 1
		M += 1
print(M)
Ans = []
for k in range(len(Answer)):
	if Answer[k] == 1:
		Ans.append(k)
print(*Ans[0:], end='\t')


N = int(input())
A = list(map(int, input().split()))
b = [0 for _ in range(N)]
for i in range(N, 0, -1):
	b[i - 1] = 0 if sum(b[i - 1::i]) % 2 == A[i - 1] else 1
ans = [str(i + 1) for (i, x) in enumerate(b) if x == 1]
print(len(ans))
if ans:
	print(' '.join(ans))


n = int(input())
a = [int(x) for x in input().split()]
m = []
for i in range(n, 0, -1):
	t = 0
	for j in range(i, n + 1, i):
		t = t + a[j - 1]
	if t % 2 != a[i - 1]:
		if a[i - 1] == 1:
			a[i - 1] = 0
		else:
			a[i - 1] = 1
	if a[i - 1] == 1:
		m.append(i)
print(len(m))
for i in m:
	print(i)
	print(' ')


N = int(input())
A = [int(_) for _ in input().split()]
cs = [0] * N
for i in range(N):
	j = N - i
	cs[j - 1] = (A[j - 1] + sum(cs[j - 1::j])) % 2
rs = []
for (i, v) in enumerate(cs):
	if v:
		rs.append(i + 1)
print(len(rs))
print(*rs)


n = int(input())
A = list(map(int, input().split()))
filled = [0] * (n + 1)
ans = []
for i in range(n - 1, -1, -1):
	if sum(filled[::i + 1][1:]) % 2 != A[i]:
		filled[i + 1] = 1
		ans.append(i + 1)
print(len(ans))
print(' '.join(map(str, ans)))


n = int(input())
a = list(map(int, input().split()))
l = [-1 for _ in range(n)]
for i in reversed(range(1, n + 1)):
	si = 0
	j = 2 * i - 1
	while j <= n - 1:
		si += l[j]
		j += i
	si = si % 2
	if si == 0:
		l[i - 1] = a[i - 1]
	elif a[i - 1] == 0:
		l[i - 1] = 1
	else:
		l[i - 1] = 0
b = []
for i in range(n):
	if l[i] == 1:
		b.append(i + 1)
print(len(b))
if len(b) != 0:
	print(*b)


def main():
	N = int(input())
	A = reversed(list(map(int, input().split())))
	balls = [0] * (N + 1)
	for (i, a) in enumerate(A):
		s = sum([balls[j] for j in range((N - i) * 2, N + 1, N - i)])
		if a == 1 and s % 2 == 0 or (a == 0 and s % 2 == 1):
			balls[N - i] = 1
	print(sum(balls))
	idx = [str(i) for (i, flag) in enumerate(balls) if flag == 1]
	print(' '.join(idx))

def __starting_point():
	main()
__starting_point()


N = int(input())
a = list(map(int, input().split()))
b = [0] * N
c = []
cnt = 0
for i in range(1, N + 1)[::-1]:
	if sum(b[i - 1::i]) % 2 != a[i - 1]:
		b[i - 1] = 1
		c.append(i)
		cnt += 1
print(cnt)
if len(c) > 0:
	print(*c, sep='\n')


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n - 1, -1, -1):
	b[i] = (a[i] + sum(b[i::i + 1])) % 2
l = [x + 1 for (x, y) in enumerate(b) if y == 1]
print(len(l))
print(*l)


N = int(input())
A = list(map(int, input().split()))
ans = []
box = [0] * N
for i in reversed(range(1, N + 1)):
	asum = sum(box[i - 1::i])
	if asum % 2 + A[i - 1] == 1:
		box[i - 1] = 1
		ans.append(i)
print(len(ans))
print(*ans)


N = int(input())
A = list(map(int, input().split(' ')))
l = [0] * N
p = []
for i in range(N - 1, -1, -1):
	m = sum(l[i::i + 1]) % 2
	if A[i] == m:
		continue
	l[i] = 1
	p.append(i)
print(len(p))
for p_i in p:
	print(p_i + 1)


n = int(input())
a = list(map(int, input().split()))
ls = [0] * (n + 1)
ans = []
for i in reversed(list(range(n))):
	if sum(ls[::i + 1][1:]) % 2 != a[i]:
		ls[i + 1] = 1
		ans.append(i + 1)
print(sum(ls))
if ans:
	print(' '.join(map(str, ans)))


N = int(input())
A = [int(x) for x in input().split()]
M = 0
for i in range(N, 0, -1):
	t = 0
	for j in range(i, N + 1, i):
		t += A[j - 1]
	if t % 2 != A[i - 1]:
		A[i - 1] = (A[i - 1] + 1) % 2
	if A[i - 1]:
		M += 1
print(M)
if M > 0:
	for i in range(N):
		if A[i]:
			print(i + 1, '', end='')
	print()


INT = lambda : int(input())
INTM = lambda : map(int, input().split())
STRM = lambda : map(str, input().split())
STR = lambda : str(input())
LIST = lambda : list(map(int, input().split()))
LISTS = lambda : list(map(str, input().split()))

def do():
	n = INT()
	A = LIST()
	flg = True
	la = len(A)
	bool = [False] * (n + 1)
	B = []
	for i in range(la - 1, -1, -1):
		a = A[i]
		s = i + 1
		temp = 0
		for j in range(n // s + 1):
			if j == 0:
				continue
			if bool[j * s]:
				temp += 1
		if temp % 2 != a:
			B.append(s)
			bool[s] = True
	B = sorted(B)
	print(len(B))
	if len(B) != 0:
		print(*B)

def __starting_point():
	do()
__starting_point()


n = int(input())
A = [0] + list(map(int, input().split()))
for i in reversed(range(1, n + 1)):
	if sum(A[::i]) % 2 != A[i]:
		A[i] ^= 1
print(sum(A))
if sum(A) != 0:
	for (i, a) in enumerate(A):
		if a == 1:
			print(i)


N = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)
ans = []
for i in reversed(range(1, N + 1)):
	if sum(A[i::i]) % 2 != A[i]:
		A[i] = (A[i] + 1) % 2
	if A[i] == 1:
		ans.append(i)
print(len(ans))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
b = set()
c = [0] * n
for i in range(n, 0, -1):
	x = 0
	for j in range(2 * i, n + 1, i):
		x += c[j - 1]
	if a[i - 1] != x % 2:
		c[i - 1] += 1
		b.add(i)
print(len(b))
print(*b)


n = int(input())
a = list(map(int, input().split()))
b = [None] * n
for i in range(n, 0, -1):
	s = 0
	for j in range(2 * i, n + 1, i):
		s += b[j - 1]
	b[i - 1] = a[i - 1] ^ s % 2
print(sum(b))
print(*[ind + 1 for (ind, i) in enumerate(b) if i])


n = int(input())
A = list(map(int, input().split()))
B = []
S = [0] * n
for i in range(n - 1, -1, -1):
	if sum(S[i::i + 1]) % 2 ^ A[i]:
		B.append(i + 1)
		S[i] ^= 1
print(len(B))
print(*B)


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
c = []
for i in range(1, n + 1):
	if sum(b[n - i:n + 1:n + 1 - i]) % 2 == a[n - i]:
		pass
	else:
		b[n - i] = 1
		c.append(n - i + 1)
print(len(c))
print(*c)


N = int(input())
A = [None] + [int(i) for i in input().split()]
ans = []
choose = [0] * (N + 1)
for n in range(N, 0, -1):
	x = sum(choose[2 * n::n])
	if x % 2 == A[n]:
		continue
	choose[n] += 1
	ans.append(str(n))
print(len(ans))
print(' '.join(ans))


n = int(input())
A = list(map(int, input().split()))
dp = [0] * (n + 2)
A = [0] + A
for i in range(n, 0, -1):
	tmp = 0
	for j in range(i, n + 1, i):
		tmp += dp[j]
	if A[i] != tmp % 2:
		dp[i] = 1
l = []
for i in range(1, n + 1):
	if dp[i] == 1:
		l.append(i)
if len(l) == 0:
	print(len(l))
else:
	print(len(l))
	print(*l)


N = int(input())
A = [int(x) for x in input().split()]
B = [0 for _ in range(N)]
C = []
for i in range(N, 0, -1):
	tmp = sum(B[i - 1::i])
	if tmp % 2 != A[i - 1]:
		B[i - 1] = 1
		C.append(str(i))
print(len(C))
if len(C) != 0:
	print(' '.join(C))


N = int(input())
(*A,) = map(int, input().split())
D = [[1] for _ in range(N + 1)]
for i in range(2, N + 1):
	j = 1
	while i * j <= N:
		D[i * j].append(i)
		j += 1
D = D[1:]
B = [0] * N
ans = []
i = 1
while i <= N:
	B[-i] %= 2
	if B[-i] == A[-i]:
		i += 1
		continue
	else:
		ans.append(N - i + 1)
		for d in D[-i]:
			B[d - 1] += 1
		B[-i] %= 2
	i += 1
M = len(ans)
ans.sort()
print(M)
print(*ans)


N = int(input())
A = [0] + [int(_) for _ in input().split()]
ans = [0] * (N + 1)
result = []
for i in range(N, 0, -1):
	bai = N // i
	if A[i] != sum((ans[i * b] for b in range(2, bai + 1))) % 2:
		ans[i] = 1
		result += [i]
print(len(result))
print(*result)


(n, *a) = map(int, open(0).read().split())
r = range(n)
for i in r:
	a[~i] = sum(a[~i::n - i]) % 2
print(sum(a), *[i + 1 for i in r if a[i]])


n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
res = []
for i in range(1, n + 1):
	t = sum(ans[n - i:n:n - i + 1]) % 2
	if (t - a[n - i]) % 2 == 1:
		ans[n - i] = 1
		res.append(n - i + 1)
print(sum(ans))
print(*res)


n = int(input())
a = input()
r = [None] * (n + 1)
for i in range(n, 0, -1):
	r[i] = (ord(a[2 * i - 2]) + sum(r[i * 2::i])) % 2
print(r.count(1))
print(*(i for (i, x) in enumerate(r) if x))


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n - 1, -1, -1):
	b[i] = 1 if sum(b[i + i + 1:n:i + 1]) % 2 != a[i] else 0
b = [i + 1 for i in range(n) if b[i] == 1]
m = len(b)
if m == 0:
	print(0)
else:
	print(m)
	print(*b)


N = int(input())
A = [int(a) for a in input().split()]
ANS = [0] * N
for i in range(N)[::-1]:
	ans = A[i]
	for j in range(i + 1, N + 1, i + 1):
		ans ^= ANS[j - 1]
	ANS[i] = ans
print(sum(ANS))
print(*[i + 1 for i in range(N) if ANS[i]])


N = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (N + 1)
for i in range(N, 0, -1):
	x = sum(b[2 * i::i])
	if x % 2 != a[i]:
		b[i] = 1
print(sum(b))
for i in range(1, N + 1):
	if b[i] == 1:
		print(str(int(i)), end=' ')


(n, *a) = map(int, open(0).read().split())
ans = [0] * n
for i in range(n - 1, -1, -1):
	cnt = 0
	for j in range(i + 1, n + 1, i + 1):
		cnt += ans[j - 1]
	if cnt % 2 != a[i]:
		ans[i] = 1
print(sum(ans))
for i in range(n):
	if ans[i]:
		print(i + 1)


N = int(input())
A = list(map(int, input().split()))
ans = [0 for _ in range(N)]
ans_num = 0
ans_list = ''
for i in range(N):
	tmp = N - i
	s = 0
	for j in range(tmp, N + 1, tmp):
		s += ans[j - 1]
	if s % 2 != A[tmp - 1]:
		ans[tmp - 1] = 1
		ans_num += 1
		ans_list += str(tmp)
		ans_list += ' '
print(ans_num)
print(ans_list[:-1])


N = int(input())
A = list(map(int, input().split()))
d = [0] * N
for i in reversed(range(1, N + 1)):
	n = 1
	t = 0
	while i * n <= N:
		t += d[i * n - 1]
		n += 1
	d[i - 1] = (t + A[i - 1]) % 2
res = [i + 1 for (i, x) in enumerate(d) if x]
print(len(res))
print(*res)


n = int(input())
an = [int(i) for i in input().split()]
ans = ''
if sum(an) == 0:
	print(0)
	exit()
for i in range(n // 2 - 1, -1, -1):
	an[i] = sum(an[i * 2 + 1::i + 1]) % 2 ^ an[i]
print(sum(an))
for i in range(n):
	if an[i]:
		ans += str(i + 1) + ' '
print(ans)


(N, A) = (int(input()), list(map(int, input().split())))
(b, r) = ([0] * N, [])
for (i, x) in enumerate(reversed(A)):
	if not x == sum(b[N - i - 1::N - i]) % 2:
		b[N - 1 - i] = 1
for (i, x) in enumerate(b):
	if x:
		r.append(i + 1)
print(len(r))
print(' '.join(map(str, r)))


N = int(input())
Ali = list(map(int, input().split()))
bli = [0] * (N + 1)
M = 0
for z in range(N):
	i = N - z
	sb = 0
	for j in range(i * 2, N + 1, i):
		sb += bli[j]
	if sb % 2 != Ali[i - 1]:
		bli[i] = 1
		M += 1
print(M)
cnt = 0
for i in range(N + 1):
	if bli[i] == 1:
		cnt += 1
		if cnt == M:
			print(i)
		else:
			print(i, end=' ')


N = int(input())
(*A,) = map(int, input().split())
b = [0] * N
for i in range(N - 1, -1, -1):
	chk = sum(b[i:N:i + 1])
	if chk % 2 ^ A[i]:
		b[i] = 1
print(sum(b))
ans = []
for (i, v) in enumerate(b):
	if v == 1:
		ans.append(i + 1)
print(*ans)


n = int(input())
a = list(map(int, input().split()))
ball = [0 for i in range(n)]
for i in reversed(range(n)):
	if n // 2 < i:
		ball[i] = a[i]
	elif (sum(ball[i::i + 1]) - a[i]) % 2 == 0:
		ball[i] = 0
	else:
		ball[i] = 1
num = [str(i + 1) for (i, x) in enumerate(ball) if x == 1]
if len(num) == 0:
	print('0')
else:
	print(len(num))
	num = ' '.join(num)
	print(num)


n = int(input())
l = list(map(int, input().split()))
box = [0] * (n + 1)
for i in range(n):
	k = n - i
	count = 0
	for j in range(k, n + 1, k):
		count += box[j]
	if count % 2 != l[k - 1]:
		box[k] = 1
ll = []
for i in range(1, n + 1):
	if box[i] == 1:
		ll.append(i)
print(box.count(1))
print(*ll)


n = int(input())
ns = list(map(int, input().split()))
rslt = [0] * n
r = n - 1
while r >= 0:
	if sum(rslt[r:n:r + 1]) % 2 != ns[r]:
		rslt[r] += 1
	r -= 1
print(sum(rslt))
if sum(rslt):
	print(*[i + 1 for (i, num) in enumerate(rslt) if num == 1])


N = int(input())
aN = [int(i) for i in input().split()]
bN = [0] * N
for i in range(N, 0, -1):
	if sum(bN[i - 1::i]) % 2 != aN[i - 1]:
		bN[i - 1] = 1
print(sum(bN))
if sum(bN) != 0:
	print(*[i + 1 for (i, b) in enumerate(bN) if b == 1])


n = int(input())
A = list(map(int, input().split()))
ans = [0] * n
for i in range(n)[::-1]:
	if i >= n // 2:
		ans[i] = A[i]
	else:
		tmp = 0
		j = i + 1
		while j <= n:
			tmp += ans[j - 1]
			j += i + 1
		if A[i] == 1:
			if tmp % 2 != A[i]:
				ans[i] = A[i]
		elif tmp % 2 == 1:
			ans[i] = 1
print(sum(ans))
print(*[i + 1 for i in range(n) if ans[i] == 1])


n = int(input())
a = list(map(int, input().split()))
for i in range(n - 1, -1, -1):
	s = sum(a[i::i + 1])
	if s % 2 != a[i]:
		a[i] = 1 - a[i]
print(a.count(1))
print(*[i + 1 for (i, x) in enumerate(a) if x])


N = int(input())
A = [0] + list(map(int, input().split()))
Ans = [0] * (N + 1)
for (i, a) in zip(list(range(N, 0, -1)), A[:0:-1]):
	n = 0
	for aj in Ans[i * 2::i]:
		n ^= aj
	Ans[i] = n ^ a
Ans = [i for (i, a) in enumerate(Ans[1:], 1) if a]
print(len(Ans))
print(' '.join(map(str, Ans)))


(N, *A) = map(int, open(0).read().split())
x = [0] * (N + 1)
ans = []
for i in reversed(range(1, N + 1)):
	if sum(x[i::i]) % 2 != A[i - 1]:
		x[i] += 1
		ans.append(i)
print(len(ans))
if ans:
	print(*ans)


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n - 1, -1, -1):
	if a[i] != sum(b[i::i + 1]) % 2:
		b[i] = 1
ans = [i for (i, x) in enumerate(b) if x == 1]
print(len(ans))
for i in ans:
	print(i + 1, end=' ')


n = int(input())
a = [0] + [int(x) for x in input().split()]
b = [0] * (n + 1)
for s in range(n, 0, -1):
	i = s
	t = 0
	while i <= n:
		t += b[i]
		i += s
	if a[s] != t % 2:
		b[s] = 1
print(b.count(1))
for i in range(n):
	if b[i + 1] == 1:
		print(i + 1)


N = int(input())
A = [0] + [int(s) for s in input().split()]
ball = [0] * (N + 1)
for i in range(N, 0, -1):
	ball[i] = (sum(ball[i::i]) - A[i]) % 2
ans = [i for (i, v) in enumerate(ball) if v == 1]
print(len(ans))
print(*ans)


import sys
input = sys.stdin.readline

def main():
	N = int(input())
	a = list(map(int, input().split()))
	b = []
	box = [0] * (N + 1)
	for (i, r) in zip(reversed(list(range(1, N + 1))), a[::-1]):
		total_r = sum((box[j] for j in range(i, N + 1, i))) % 2
		if r == 0 and total_r == 1:
			box[i] = 1
			b.append(i)
		elif r == 1 and total_r == 0:
			box[i] = 1
			b.append(i)
	M = len(b)
	if M == 0:
		print(0)
	else:
		print(M)
		print(' '.join(map(str, b)))

def __starting_point():
	main()
__starting_point()


N = int(input())
A = list(map(int, input().split()))
B = [0] * N
for i in range(N - 1, -1, -1):
	tmp_sum = 0
	for j in range((i + 1) * 2 - 1, N, i + 1):
		tmp_sum += B[j]
		tmp_sum %= 2
	B[i] = tmp_sum ^ A[i]
print(sum(B))
print(*[i + 1 for (i, b) in enumerate(B) if b == 1])


(N, *a) = map(int, open(0).read().split())
for i in range(N)[::-1]:
	part_rem = sum(a[i::i + 1]) % 2
	if a[i] != part_rem:
		a[i] = abs(a[i] - 1)
print(sum(a))
print(*[i + 1 for (i, v) in enumerate(a) if v == 1])


n = int(input())
lst = list(map(int, input().split()))
put = [0] * n
for i in reversed(range(n)):
	if sum(put[i::i + 1]) % 2 != lst[i]:
		put[i] = 1
print(sum(put))
for (index, i) in enumerate(put):
	if i == 1:
		print(index + 1)


(n, *a) = map(int, open(0).read().split())
b = [0] * (n + 1)
for x in range(n, 0, -1):
	b[x] = (sum(b[x::x]) + a[x - 1]) % 2
print(b.count(1))
for i in range(n + 1):
	if b[i]:
		print(i, end=' ')


N = int(input())
A = list(map(int, input().split()))
B = [False] * N
for i in range(N, 0, -1):
	B[i - 1] = A[i - 1] + sum((B[j - 1] for j in range(i * 2, N + 1, i))) & 1
C = [i for (i, a) in enumerate(B, 1) if a]
print(len(C))
print(*C)


n = int(input())
(*a,) = map(int, input().split())
ans = [0] * n
for i in range(n - 1, -1, -1):
	if not sum(ans[i::i + 1]) % 2 == a[i]:
		ans[i] = 1
print(sum(ans))
print(*[i + 1 for i in range(n) if ans[i] == 1])


N = int(input())
A = [0] + list(map(int, input().split()))
ans = [0] * (N + 1)
for i in reversed(range(1, N + 1)):
	tot = 0
	for j in range(i + i, N + 1, i):
		tot += ans[j]
	if tot % 2 != A[i]:
		ans[i] = 1
M = sum(ans)
res = []
for i in range(1, N + 1):
	if ans[i] == 1:
		res.append(str(i))
print(M)
print(' '.join(res))


n = int(input())
b = list(map(int, input().split()))
a = [0] * (n + 1)
for i in range(1, n + 1):
	a[i] = b[i - 1]
ball = [0] * (n + 1)
ans = []
for i in range(n, 0, -1):
	s = 0
	j = i * 2
	while j <= n:
		s += ball[j]
		j += i
	if s % 2 != a[i]:
		ball[i] += 1
		ans.append(i)
print(len(ans))
for e in ans:
	print(e)


n = int(input())
v = list(map(int, input().strip().split()))
a = [0] * n
for i in range(n - 1, -1, -1):
	c = 0
	for j in range(i, n, i + 1):
		c ^= a[j]
	if c != v[i]:
		a[i] = 1
ans = []
for i in range(n):
	if a[i]:
		ans.append(i + 1)
print(len(ans))
print(*ans)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * n
	ans = []
	for i in range(n - 1, -1, -1):
		if sum(b[i::i + 1]) % 2 != a[i]:
			b[i] = 1
			ans.append(i + 1)
	print(len(ans))
	if len(ans):
		print(*ans)

def __starting_point():
	solve()
__starting_point()


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
bon = []
for i in range(n):
	ri = n - i - 1
	if sum(b[ri::ri + 1]) % 2 != a[ri]:
		b[ri] = 1
		bon.append(ri + 1)
print(len(bon))
print(*bon)


N = int(input())
A = list(map(int, input().split()))
B = [0] * N
ans = []
for i in range(N, 0, -1):
	cnt = sum(B[i - 1::i]) % 2
	B[i - 1] = A[i - 1] ^ cnt
	if B[i - 1]:
		ans.append(i)
print(sum(B))
print(*ans)


n = int(input())
a = [0] + list(map(int, input().split()))
b = []
c = [0] * (n + 1)
for i in range(n, 0, -1):
	cnt = 0
	t = i
	while t <= n:
		cnt += c[t]
		t += i
	if cnt % 2 != a[i]:
		c[i] = 1
		b.append(i)
b.sort()
if len(b) > 0:
	print(len(b))
	print(*b)
else:
	print(0)


N = int(input())
A = list(map(int, input().split()))
res = [-1] * N
for i in reversed(range(1, N + 1)):
	p = N // i * i
	s = 0
	while res[p - 1] != -1:
		s += res[p - 1]
		s %= 2
		p -= i
	res[p - 1] = (A[p - 1] - s) % 2
print(sum(res))
for i in range(N):
	if res[i] == 1:
		print(i + 1)


N = int(input())
a = [0] + list(map(int, input().split()))
ans = [0] * (N + 1)
an = []
for i in range(N, 0, -1):
	if sum(ans[i * 2::i]) % 2 != a[i]:
		ans[i] = 1
		an.append(i)
print(len(an))
Ans = [str(x) for x in an]
print(' '.join(Ans))


n = int(input())
a = list(map(int, input().split()))
ans = a[:]
for i in reversed(range(n)):
	ans[i] = sum(ans[i::i + 1]) % 2
print(sum(ans))
print(*[i + 1 for i in range(n) if ans[i]])


N = int(input())
A = [0] + list(map(int, input().split()))
for n in range(N):
	A[N - n] = sum(A[N - n::N - n]) % 2
print(sum(A), '\n', *(i for (i, x) in enumerate(A) if x))


n = int(input())
a = [int(i) for i in input().split()]
box = [0] * n
ans = []
for i in range(n, 0, -1):
	if sum(box[i - 1:n:i]) % 2 != a[i - 1]:
		box[i - 1] = 1
		ans.append(i)
print(len(ans))
print(*ans)


N = int(input())
A = [int(i) for i in input().split()]
B = [0] * N
for i in reversed(range(N)):
	B[i] = (A[i] - sum(B[i::i + 1])) % 2
ans = [i + 1 for (i, b) in enumerate(B) if b == 1]
print(len(ans))
print(*ans)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	ans = [-1 for i in range(n)]
	for i in range(n):
		c = n // (n - i)
		if c < 2:
			if a[n - 1 - i] == 1:
				ans[n - 1 - i] = 1
			else:
				ans[n - 1 - i] = 0
		else:
			s = 0
			for j in range(2, c + 1):
				s += ans[j * (n - i) - 1]
			ans[n - i - 1] = (s + a[n - 1 - i]) % 2
	a = []
	for i in range(n):
		if ans[i] == 1:
			a.append(i + 1)
	if len(a) == 0:
		print(0)
	else:
		print(len(a))
		print(' '.join(list(map(str, a))))

def __starting_point():
	main()
__starting_point()


n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
c = []
for i in range(n, 0, -1):
	tmp = sum(b[i - 1::i])
	if tmp % 2 != a[i - 1]:
		b[i - 1] = 1
		c.append(str(i))
print(len(c))
if len(c) != 0:
	print(' '.join(c))


n = int(input())
a = list(map(int, input().split()))
r = [0] * n
for i in range(n)[::-1]:
	if sum(r[i::i + 1]) % 2 != a[i]:
		r[i] = 1
print(sum(r))
for (index, i) in enumerate(r):
	if i == 1:
		print(index + 1)


import math

def main():
	N = int(input())
	A = [int(a) for a in input().split(' ')]
	B = [0] * N
	if N == 1:
		if A[0] == 1:
			print(1)
			print(1)
		else:
			print(0)
		return 0
	for i in range(1, N):
		for j in range(math.ceil(N / (i + 1)), math.floor(N / i) + 1):
			ball = 0
			for k in range(2 * j, N + 1, j):
				ball += B[k - 1]
			B[j - 1] = (ball % 2 + A[j - 1]) % 2
	ans = [str(x + 1) for (x, v) in enumerate(B) if v == 1]
	print(len(ans))
	if len(ans) > 0:
		print(' '.join(ans))
main()


n = int(input())
a = list(map(int, input().split()))
a = [0] + a
s = [0] * (n + 1)
for i in range(n, 0, -1):
	if sum(s[i::i]) % 2 == a[i]:
		s[i] = 0
	else:
		s[i] = 1
print(sum(s))
b = ''
for i in range(1, n + 1):
	if s[i] == 1:
		b += str(i) + ' '
if b:
	print(b)


N = int(input())
lsa = list(map(int, input().split()))
ls = [0] * (N + 1)
for i in range(N, 0, -1):
	k = 0
	c = 2 * i
	while c <= N:
		k += ls[c]
		c += i
	if k % 2 == lsa[i - 1] % 2:
		continue
	ls[i] = 1
ls.pop(0)
M = ls.count(1)
print(M)
if M != 0:
	ls1 = []
	for i in range(N):
		if ls[i] == 1:
			ls1.append(i + 1)
	ls2 = [str(i) for i in ls1]
	print(' '.join(ls2))


N = int(input())
A = tuple(map(int, input().split()))
state = [0] * (N + 1)
for i in range(N, 0, -1):
	if N < i + i:
		state[i] = A[i - 1]
	else:
		state[i] = A[i - 1]
		j = i + i
		while j <= N:
			state[i] ^= state[j]
			j += i
ans = [str(i) for (i, x) in enumerate(state) if x == 1]
print(len(ans))
if ans:
	print(' '.join(ans))


n = int(input())
a = [0] + [int(i) for i in input().split()]
b = [0] * (n + 1)
for i in range(1, n + 1)[::-1]:
	mul_sum = sum((b[x] for x in range(i + i, n + 1, i)))
	b[i] = mul_sum % 2 ^ a[i]
print(sum(b))
print(' '.join((str(i) for i in range(1, n + 1) if b[i])))


import math
N = int(input())
A = [0] + list(map(int, input().split()))
B = [0] * (N + 1)
s = 0
for i in reversed(range(1, N + 1)):
	ball = 0
	for j in range(i, N + 1, i):
		ball += B[j]
	if ball % 2 != A[i]:
		B[i] = 1
		s += 1
print(s)
print(*[i for (i, b) in enumerate(B) if b == 1], sep=' ')


n = int(input())
a = input()
b = [None] * (n + 1)
r = []
for i in range(n, 0, -1):
	b[i] = (ord(a[2 * i - 2]) + sum(b[i * 2::i])) % 2
	if b[i]:
		r.append(i)
print(len(r))
print(*r)


n = int(input())
a = [int(x) for x in input().split()]
ans = [0] * n
for i in range(n - 1, -1, -1):
	ans[i] = sum(ans[i + i + 1:n:i + 1]) % 2 != a[i]
print(sum(ans))
for i in range(n):
	if ans[i] == 1:
		print(i + 1)


n = int(input())
l = tuple(map(int, input().split()))
ret = []
ll = [0] * n
ans = 0
for i in range(n, 0, -1):
	s = l[i - 1]
	for j in range(2, n // i + 1):
		s -= ll[j * i - 1]
		s %= 2
	ll[i - 1] = s
	ans += s
	if s:
		ret.append(i)
print(ans)
if ans:
	print(*ret, sep=' ')


n = int(input())
a = [0] + list(map(int, input().split()))
c = [0] * (n + 1)
d = []
for i in reversed(range(1, n + 1)):
	s = sum(c[::i])
	if s % 2 != a[i]:
		c[i] += 1
		d.append(str(i))
print(sum(c))
if sum(c) > 0:
	print(' '.join(d))


n = int(input())
a = list(map(int, input().split()))
d = [0 for i in range(n + 1)]
ans = [0 for i in range(n + 1)]
for i in range(n, 0, -1):
	c = 0
	for j in range(i * 2, n + 1, i):
		c += ans[j]
	if c % 2 ^ a[i - 1]:
		ans[i] = 1
r = ''
c = 0
for i in range(1, n + 1):
	if ans[i]:
		c += 1
		r += str(i) + ' '
print(c)
print(r[:-1])


n = int(input())
a = list(map(int, input().split()))
p = [0 for i in range(n + 1)]
ans = 0
q = []
for i in reversed(range(1, n + 1)):
	if sum(p[i:n + 1:i]) % 2 != a[i - 1]:
		p[i] += 1
		ans += 1
		q.append(i)
print(ans)
print(*q)


N = int(input())
A = list(map(int, input().split()))
B = [0] * (N + 1)
for i in range(N, 0, -1):
	B[i] = sum((B[x] for x in range(i, N + 1, i))) % 2 != A[i - 1]
print(sum(B))
print(*[i for (i, v) in enumerate(B) if v])


n = int(input())
A = list(map(int, input().split()))[::-1]
B = [0] * n
for i in range(n):
	k = n - i
	if A[i] != B[k - 1::k].count(1) % 2:
		B[k - 1] = 1
o = B.count(1)
print(o)
P = [[i + 1 for (i, x) in enumerate(B) if x == 1]]
if o != 0:
	print(*P[0])


n = int(input())
A = list(map(int, input().split()))
B = [0] * (n + 1)
(C, cnt) = ([], 0)
for i in range(1, n + 1)[::-1]:
	sum_list = sum([B[j] for j in range(i, n + 1, i)])
	if sum_list % 2 != A[i - 1]:
		B[i] = 1
		cnt += 1
		C.append(i)
print(cnt)
print(*C[::-1])


n = int(input())
a = list(map(int, input().split()))
res = [0] * n
for i in range(n - 1, -1, -1):
	res[i] = (a[i] + sum(res[2 * i + 1:n:i + 1])) % 2
print(res.count(1))
for i in range(n):
	if res[i] == 1:
		print(i + 1, end=' ')


N = int(input())
arr = [0] + list(map(int, input().split(' ')))
for i in range(N // 2, 0, -1):
	arr[i] = sum(arr[i::i]) % 2
ans = [i for (i, j) in enumerate(arr) if j == 1]
print(len(ans))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n // 2)] + a[n // 2:]
for i in range(n // 2 - 1, -1, -1):
	b[i] = abs(a[i] - sum(b[i::i + 1]) % 2)
print(sum(b))
print(*[i + 1 for (i, bi) in enumerate(b) if bi > 0])


N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
for (i, a) in enumerate(A[::-1]):
	n = m = N - i
	s = 0
	while m <= N:
		s += ans[m - 1]
		m += n
	ans[n - 1] = s % 2 ^ a
ans = [i + 1 for (i, a) in enumerate(ans) if a]
print(len(ans))
if ans:
	print(*ans, sep='\n')


def resolve():
	N = int(input())
	As = [int(item) for item in input().split()]
	box = set()
	for i in range(N):
		num = N - i
		sum_num = 0
		for j in range(1, N // num + 1):
			if j * num in box:
				sum_num += 1
		if As[num - 1] != sum_num % 2:
			box.add(num)
	print(len(box))
	for item in box:
		print(item)

def __starting_point():
	resolve()
__starting_point()


n = int(input())
a = list(map(int, input().split()))
ans = [False] * n
for i in range(n // 2, n):
	ans[i] = a[i]
for i in range(n // 2 - 1, -1, -1):
	mod = False
	for j in range(i, n, i + 1):
		if ans[j] == 1:
			mod = not mod
	mod = 1 if mod else 0
	ans[i] = True if mod != a[i] else False
cnt = 0
ind = []
for i in range(n):
	if ans[i] == True:
		cnt += 1
		ind.append(i + 1)
print(cnt)
if cnt > 0:
	print(' '.join(map(str, ind)))


n = int(input())
a = [None] + [int(i) for i in input().split()]
check = [0] * (n + 1)
ans = []
for i in range(n, 0, -1):
	if sum(check[2 * i::i]) % 2 == a[i]:
		continue
	else:
		check[i] = 1
		ans.append(i)
print(len(ans))
print(*ans)


n = int(input())
A = list(map(int, input().split()))
B = []
C = [0] * n
for i in reversed(range(n)):
	if sum(C[i::i + 1]) % 2 != A[i]:
		B.append(i + 1)
		C[i] += 1
print(len(B))
print(' '.join(map(str, B)))


n = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(n, 0, -1):
	for j in range(i, n + 1, i):
		b[i] ^= b[j]
	b[i] ^= a[i]
print(sum(b))
for i in range(1, n + 1):
	if b[i] == 1:
		print(i)


n = int(input())
a = list(map(int, input().split()))
r = [None] * (n + 1)
for i in range(n, 0, -1):
	r[i] = (a[i - 1] + sum(r[i * 2::i])) % 2
print(r.count(1))
print(*(i for (i, x) in enumerate(r) if x))


n = int(input())
a = list(map(int, input().split()))
ans = []
b = [0] * n
for i in range(1, n + 1)[::-1]:
	sum_i = sum(b[i - 1::i])
	if sum_i % 2 != a[i - 1]:
		ans.append(i)
		b[i - 1] = 1
print(len(ans))
if len(ans) != 0:
	print(*ans)


N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
for i in range(N):
	n = N - i
	add = A[n - 1]
	n_tmp = n
	while True:
		n_tmp += n
		if n_tmp > N:
			break
		if ans[n_tmp - 1]:
			add = 0 if add else 1
	if add:
		ans[n - 1] = 1
print(ans.count(1))
ans2 = []
for (i, v) in enumerate(ans):
	if v:
		ans2.append(i + 1)
print(*ans2)


(n, a) = open(0)
n = int(n)
b = [0] * -~n
for x in range(n, 0, -1):
	b[x] = (sum(b[x::x]) + int(a[x * 2 - 2])) % 2
print(sum(b))
print(*[i + 1 for i in range(n) if b[i + 1]])


n = int(input())
bits = list(map(int, input().split()))
ans = set()
for i in reversed(range(n)):
	for j in range(i + (i + 1), n, i + 1):
		bits[i] ^= bits[j]
	if bits[i] == 1:
		ans.add(i + 1)
print(len(ans))
print(*ans)


n = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (n + 1)
b[-1] = a[-1]
ans = []
for i in range(n, 0, -1):
	cnt = 0
	bi = i
	i += bi
	while i <= n:
		cnt += b[i]
		i += bi
	if cnt % 2 == a[bi]:
		b[bi] = 0
	else:
		b[bi] = 1
		ans.append(bi)
print(len(ans))
if ans:
	print(*ans)


N = int(input())
AL = list(map(int, input().split()))
L = []
for i in range(N - 1, -1, -1):
	s = AL[i]
	for j in range((i + 1) * 2 - 1, N, i + 1):
		s ^= AL[j]
	AL[i] = s
	if AL[i] == 1:
		L.append(i + 1)
print(len(L))
if L:
	print(*L)


from copy import deepcopy
N = int(input())
A = list(map(int, input().split()))
ans = [0] * (N // 2 + 1) + A[N // 2:]
A = [0] + A
ok = 1
for i in range(N // 2, 0, -1):
	if sum(ans[i * 2:i * (N // i) + 1:i]) % 2 == 0:
		ans[i] = A[i]
	else:
		ans[i] = 1 - A[i]
ans2 = []
for i in range(1, N + 1):
	if ans[i] == 1:
		ans2.append(i)
print(len(ans2))
if len(ans2) > 0:
	print(*ans2)


n = int(input())
lis = [0] + list(map(int, input().split()))
b = [0] * (n + 1)
for i in reversed(range(1, n + 1)):
	ball = 0
	base = i + 1
	for j in range(i, n + 1, i):
		ball += b[j]
	if ball % 2 != lis[i]:
		b[i] = 1
print(sum(b))
print(*[i for (i, b) in enumerate(b) if b == 1], sep=' ')


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
c = []
for i in range(n - 1, -1, -1):
	v = i + 1
	s = 0
	for j in range(1, 10 ** 6):
		if v * j > n:
			break
		s += b[v * j - 1]
	if s % 2 != a[i]:
		b[i] = 1
		c.append(v)
print(len(c))
for i in reversed(c):
	print(i)


N = int(input())
A = list(map(int, input().split()))
A = [0] + A
res = [0] * (N + 1)
M = 0
for i in range(N, 0, -1):
	if sum((res[j] for j in range(i, N + 1, i))) % 2 != A[i]:
		res[i] = 1
		M += 1
print(M)
print(*[k for (k, r) in enumerate(res) if r])


(N, *A) = map(int, open(0).read().split())
for n in range(N):
	A[N - n - 1] = sum(A[N - n - 1::N - n]) % 2
print(sum(A), '\n', *(i + 1 for (i, x) in enumerate(A) if x))


(N, *aa) = map(int, open(0).read().split())
ans = [None] * (N // 2) + aa[N // 2:]
for i in range(N // 2, 0, -1):
	ans[i - 1] = sum(ans[2 * i - 1::i]) % 2 ^ aa[i - 1]
p = sum(ans)
print(p)
if p:
	print(*(i + 1 for (i, v) in enumerate(ans) if v))


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
c = []
for i in reversed(range(n)):
	j = 0
	k = 2
	while k * (i + 1) <= n:
		j = j + b[k * (i + 1) - 1]
		k = k + 1
	j = j % 2
	if a[i] != j:
		b[i] = 1
print(sum(b))
for i in range(n):
	if b[i] == 1:
		print(i + 1, end=' ')


def inpl():
	return list(map(int, input().split()))
N = int(input())
A = [0] + inpl()
D = [0] * (N + 1)
for i in range(N, 0, -1):
	D[i] = sum(D[2 * i::i]) % 2 ^ A[i]
print(sum(D))
print(*[i for i in range(N + 1) if D[i]])


n = int(input())
a = [int(x) for x in input().split()]
for i in range(n, 0, -1):
	a[i - 1] = sum(a[i - 1::i]) % 2
print(sum(a))
print(' '.join([str(i + 1) for (i, j) in enumerate(a) if j == 1]))


n = int(input())
a = list(map(int, input().split()))
ret = [0] * (n + 1)
ret2 = []
for i in reversed(list(range(n))):
	if sum(ret[::i + 1][1:]) % 2 != a[i]:
		ret[i + 1] = 1
		ret2.append(i + 1)
print(sum(ret[1:]))
print(' '.join(list(map(str, ret2[::-1]))))


n = int(input())
list_A = list(map(int, input().split()))
list_N = [0] * n
for i in range(n, 0, -1):
	(k, cnt) = (0, 0)
	while True:
		if k + i > n:
			break
		if list_N[k + i - 1] == 1:
			cnt += 1
		k += i
	list_N[i - 1] = (list_A[i - 1] + cnt) % 2
ans = []
for i in range(n):
	if list_N[i] == 1:
		ans.append(i + 1)
print(len(ans))
print(*ans)


n = int(input())
a = [0] + list(map(int, input().split()))
check = [0] * (n + 1)
res = []
for i in range(n, 0, -1):
	if sum(check[2 * i::i]) % 2 == a[i]:
		continue
	else:
		check[i] = 1
		res.append(i)
print(len(res))
print(*res)


n = int(input())
a = list(map(int, input().split()))
ans = [0 for _ in range(n + 1)]
t = []
S = 0
for i in range(n):
	b = n - i
	c = (n - i) * 2
	ch = 0
	while c <= n:
		ch += ans[c]
		c += b
	if ch % 2 == 0:
		if a[b - 1] == 1:
			ans[b] += 1
			S += 1
			t.append(str(b))
	elif a[b - 1] == 0:
		ans[b] += 1
		S += 1
		t.append(str(b))
print(S)
if S > 0:
	print(' '.join(t))


import math
from math import gcd, pi, sqrt
INF = float('inf')
MOD = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 6)
import itertools
import bisect
from collections import Counter, deque

def i_input():
	return int(input())

def i_map():
	return map(int, input().split())

def i_list():
	return list(i_map())

def i_row(N):
	return [i_input() for _ in range(N)]

def i_row_list(N):
	return [i_list() for _ in range(N)]

def s_input():
	return input()

def s_map():
	return input().split()

def s_list():
	return list(s_map())

def s_row(N):
	return [s_input for _ in range(N)]

def s_row_str(N):
	return [s_list() for _ in range(N)]

def s_row_list(N):
	return [list(s_input()) for _ in range(N)]

def main():
	M = i_input()
	B = [0] + i_list()
	N = [0] * (M + 1)
	for i in range(M, 0, -1):
		k = 2 * i
		trial = 0
		while k <= M:
			trial += N[k]
			k += i
		if trial % 2 == B[i]:
			continue
		else:
			N[i] = 1
	s = sum(N)
	print(s)
	if s > 0:
		for (i, k) in enumerate(N):
			if k > 0:
				print(i)

def __starting_point():
	main()
__starting_point()


(n, a, d, l) = (int(input()), list(map(int, input().split())), set(), 0)
b = [0] * n
for i in range(n - 1, -1, -1):
	c = 0
	for j in range(2 * i + 1, n, i + 1):
		c = (c + b[j]) % 2
	if a[i] != c:
		b[i] += 1
		d.add(i + 1)
		l += 1
print(l)
print(*[d.pop() for _ in range(l)])


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
ans = 0
for i in range(n)[::-1]:
	t = 0
	j = (i + 1) * 2
	while j <= n:
		t += b[j - 1]
		j += i + 1
	if a[i] == 0:
		if t % 2 == 0:
			b[i] = 0
		else:
			b[i] = 1
			ans += 1
	elif t % 2 == 0:
		b[i] = 1
		ans += 1
	else:
		b[i] = 0
print(ans)
l = []
for i in range(n):
	if b[i] == 1:
		l.append(str(i + 1))
print(' '.join(l))


n = int(input())
a = list(map(int, input().split()))
t = [0] * n
p = []
g = 0
for i in range(n - 1, -1, -1):
	if sum(t[i::i + 1]) % 2 != a[i]:
		t[i] = 1
		p.append(i + 1)
		g += 1
print(g)
print(*p[::-1])


N = int(input())
A = list(map(int, input().split()))
B = (N + 1) * [0]
for n in range(N, 0, -1):
	B[n] = (sum(B[n::n]) + A[n - 1]) % 2
print(B.count(1))
for n in range(N + 1):
	if B[n]:
		print(n, end=' ')


N = int(input())
A = list(map(int, input().split()))
ans = [0] * (N + 1)
for i in range(N, 0, -1):
	cnt = 0
	for j in range(i * 2, N + 1, i):
		cnt += ans[j]
	ans[i] = cnt & 1 ^ A[i - 1]
print(sum(ans))
for i in range(1, N + 1):
	if ans[i]:
		print(i, end=' ')


N = int(input())
A = list(map(int, input().split()))
A = [0] + A
B = [0] * (N + 1)
for i in range(N):
	k = N - i
	c = 0
	for j in range(k, N + 1, k):
		c += B[j]
		c %= 2
	if A[k] != c:
		B[k] = 1
print(sum(B))
for i in range(len(B)):
	if B[i] == 1:
		print(i)


n = int(input())
alst = list(map(int, input().split()))
divisor_lst = [[0] for _ in range(n)]
ans = []
for i in range(2, n + 1):
	for k in range(i * 2, n + 1, i):
		divisor_lst[k - 1].append(i - 1)
for i in range(n - 1, -1, -1):
	if alst[i] == 1:
		for j in divisor_lst[i]:
			alst[j] += 1
			alst[j] %= 2
		ans.append(i + 1)
print(len(ans))
print(*ans)


N = int(input())
a = list(map(int, input().split()))
ans = [0 for i in range(N)]
ans2 = []
for i in range(N):
	p = N - 1 - i
	if a[p] != sum(ans[p::p + 1]) % 2:
		ans[p] = 1
		ans2.append(str(p + 1))
print(sum(ans))
print(' '.join(ans2))


N = int(input())
A = list(map(int, input().split()))
box = [0] * (N + 1)
res = []
for i in range(1, N + 1)[::-1]:
	s = 0
	for j in range(1, N // i):
		s += box[(j + 1) * i]
	if s % 2 != A[i - 1]:
		box[i] = 1
		res.append(i)
print(len(res))
print(*res)


import sys
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.141592653589793

def read_str():
	return sys.stdin.readline().strip()

def read_int():
	return int(sys.stdin.readline().strip())

def read_ints():
	return map(int, sys.stdin.readline().strip().split())

def read_ints2(x):
	return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())

def read_str_list():
	return list(sys.stdin.readline().strip().split())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def GCD(a: int, b: int) -> int:
	return b if a % b == 0 else GCD(b, a % b)

def LCM(a: int, b: int) -> int:
	return a * b // GCD(a, b)

def Main():
	n = read_int()
	a = read_int_list()
	b = [0] * n
	ans = []
	for i in range(n - 1, -1, -1):
		if sum(b[i::i + 1]) % 2 != a[i]:
			b[i] = 1
			ans.append(i + 1)
	print(len(ans))
	if len(ans):
		print(*ans)

def __starting_point():
	Main()
__starting_point()


n = int(input())
a = [0] + list(map(int, input().split()))
boxes = [0] * (n + 1)
m = 0
b = []
for i in reversed(range(1, n + 1)):
	if sum(boxes[i::i]) % 2 != a[i]:
		boxes[i] = 1
		m += 1
		b.append(i)
print(m)
print(*b)


(N, *A) = map(int, open(0).read().split())
A = [0] + A
B = [0] * (N + 1)
sum_B = 0
for i in range(N, 0, -1):
	if sum((B[j] for j in range(i, N + 1, i))) % 2 != A[i]:
		B[i] = 1
		sum_B += 1
print(sum_B)
print(*[i for (i, b) in enumerate(B) if b])


n = int(input())
a = list(map(int, input().split()))
ans = []
b = [0] * n
for i in reversed(range(n)):
	if sum(b[i::i + 1]) % 2 != a[i]:
		b[i] += 1
		ans.append(i + 1)
print(sum(b))
print(*sorted(ans))


n = int(input())
a = list(map(int, input().split()))
hako = [0] * n
for i in range(n, 0, -1):
	tmp = i
	su = 0
	while tmp <= n:
		su += hako[tmp - 1]
		tmp += i
	if su % 2 == a[i - 1]:
		continue
	else:
		hako[i - 1] = 1
print(hako.count(1))
for i in range(n):
	if hako[i] == 1:
		print(i + 1, end=' ')


N = int(input())
a = [0] + list(map(int, input().split()))
ls = [0] * (N + 1)
for i in range(N, 0, -1):
	sm = 0
	for j in range(i, N + 1, i):
		sm += ls[j]
	ls[i] = sm % 2 ^ a[i]
b = [i for i in range(N + 1) if ls[i] == 1]
print(len(b))
print(*b)


n = int(input())
a = list(map(int, input().split()))
b = []
lst = [0] * n
for (i, x) in reversed(list(enumerate(a))):
	if sum(lst[i::i + 1]) % 2 != x:
		lst[i] += 1
		b.append(i + 1)
print(len(b))
if len(b) > 0:
	print(*reversed(b))


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	ans = set()
	for i in range(n, 0, -1):
		now = 0
		for j in range(2 * i, n + 1, i):
			if j in ans:
				now += 1
		if now % 2 != a[i - 1]:
			ans.add(i)
	return ans

def __starting_point():
	x = solve()
	print(len(x))
	print(*x, sep=' ')
__starting_point()


N = int(input())
A = [int(x) for x in input().split()]
B = [0] * N
for i in range(N - 1, -1, -1):
	ai = A[i]
	for j in range(i, N, i + 1):
		ai ^= B[j]
	B[i] = ai
print(sum(B))
if sum(B):
	print(' '.join([str(i + 1) for i in range(N) if B[i]]))


n = int(input())
a = list(map(int, input().split()))
dp = [0 for i in range(n)]
dp[n - 1] = a[n - 1]
for i in range(n, 0, -1):
	num = 0
	for j in range(i * 2, n + 1, i):
		num = num + dp[j - 1]
	if num % 2 == a[i - 1]:
		dp[i - 1] = 0
	else:
		dp[i - 1] = 1
print(dp.count(1))
for i in range(n):
	if dp[i] == 1:
		print(i + 1, end=' ')


N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N + 1)
for i in range(N, 0, -1):
	j = 1
	cnt = 0
	while i * j <= N:
		cnt += B[i * j]
		j += 1
	flg = cnt % 2
	if A[i] != flg:
		B[i] = 1
print(sum(B))
for (i, b) in enumerate(B):
	if b == 1:
		print(i)


N = int(input())
A = [0] + list(map(int, input().split()))
B = [0] * (N + 1)
S = set()
for i in range(N, 0, -1):
	if sum(B[i::i]) % 2 != A[i]:
		B[i] = 1
		S.add(i)
print(len(S))
print(*S)


N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
index = []
M = 0
for i in range(N - 1, -1, -1):
	a = ans[i:N:i + 1]
	if sum(a) % 2 == A[i]:
		ans[i] = 0
	else:
		ans[i] = 1
		index.append(i + 1)
		M += 1
print(M)
print(*index[::-1])