Problem:
 Score : 400 points    Problem Statement 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 1 3
1 0 0      Sample Output 1 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.       Sample Input 2 5
0 0 0 0 0      Sample Output 2 0  Putting nothing in the boxes can be a good set of choices.

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
h = [0]*n
p = []

for i in reversed(range(n)):
    k = i+1
    if k > n/2:
        h[i] = a[i]
        if a[i] == 1:
            p.append(k)
        continue
    s = 0
    for j in range(1,n//k):
        s += h[k*(j+1)-1]
    s %= 2
    if s != a[i]:
        h[i] = 1
        p.append(k)

t = len(p)

print(t)

if t != 0:
    print(' '.join([str(u) for u in p]))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

B = [0] * N
ans = []
for i in range(N - 1, -1, -1):
    num = 0
    for j in range(2 * (i + 1), N + 1, i + 1):
        num += B[j - 1]
    if (num & 1) ^ A[i]:
        B[i] = 1
        ans.append(i + 1)

count = len(ans)
print(count)
if count > 0:
    print(' '.join(map(str, ans)))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)


def calc_div(n):
    d = 1
    div = []
    while d * d <= n:
        if n % d == 0:
           div.append(d)
           if d != n // d:
               div.append(n // d)
        d += 1
    return div


b = []
parity = [0] * (N+1)
for i in range(N, 0, -1):
    if parity[i] != a[i]:
        b.append(i)
        div = calc_div(i)
        for d in div:
            parity[d] = (parity[d] + 1) % 2

print(len(b))
print(" ".join(map(str, b)))

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

Solution (Python):
import sys

def divisor(N, B):
    i = 1
    d = []
    while i ** 2 <= N:
        if N % i == 0:
            B[i-1] = (B[i-1] + 1) % 2
            if i ** 2 < N: B[N // i - 1] = (B[N//i - 1] + 1) % 2 
        i += 1
    return 0


def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [0] * N
    ans = []
    M = 0

    for i in reversed(range(N)):
        if B[i] != A[i]:
            divisor(i+1, B)
            M += 1
            ans.append(i+1)

    print(M)
    print(" ".join(map(str, ans)))

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
def set_ball(i):
    index = i
    ball_count = 0
    while(True):
        ball_count += ball_status[index]
        index += i + 1
        if(index  >= N):
            break
    return (ball_count % 2) != a_list[i]

N = int(input())
a_list = list(map(int, input().strip().split()))

ball_status = [0 for i in range(N)]
for i in range(N):
    flag = set_ball(N-1-i)
    if(flag):
        ball_status[N-1-i] = 1
throw_balls = sum(ball_status)
print(throw_balls)
if(throw_balls > 0):
    ans = ""
    for i in range(N):
        if(ball_status[i] == 1):
            ans += str(i+1)
            ans += " "
    print(ans[:-1])

Solution (Python):
N = int(input())
A = [0] + list(map(int, input().split()))

B = [0] * (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] = 1

for i in range(1, N + 1):
    tmp = 0
    for j in range(i, N + 1, i):
        tmp += B[j]
    if A[i] != tmp % 2:
        print(-1)
        exit()

print(sum(B))
ans = []
for i, b in enumerate(B):
    if b == 1:
        ans.append(i)
if len(ans) > 0:
    print(*ans, sep=' ')

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

from operator import xor
from functools import reduce

B = [0]*N

for i in range(N)[::-1]:
  B[i] = reduce(xor, B[i:N:(i+1)])^A[i]
  
ans = [i+1 for i,b in enumerate(B) if b==1]
print(len(ans))
for a in ans:
  print(a)

Solution (Python):
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]])))

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def divisors(m: int):
    i = 1
    div = []
    while i * i <= m:
        if m % i == 0:
            div.append(i)
            div.append(m // i)
        i += 1

    return list(set(div))

n = ni()
a = [0] + list(li())
b = [0]*(n+1)
ans = []
for i in range(n, 0, -1):
    into = False
    if b[i] % 2 != a[i]:
        b[i] += 1
        ans.append(i)
        into = True

    if into:
        bi_div = divisors(i)

        for divi in bi_div:
            b[divi] += 1

print(len(ans))
if len(ans) > 0:
    print(*ans)

Solution (Python):

from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    n = int(input())
    a = [0] + [int(x) for x in input().split()]
    b = [0] * (n + 1)

    for i in range(n, 0, -1):
        tot = 0
        for j in range(2 * i, n + 1, i):
            tot += b[j]
        tot %= 2
        b[i] = tot if a[i] == 0 else 1 - tot

    for i in range(1, n + 1):
        tot = 0
        for j in range(i, n + 1, i):
            tot += b[j]
        if tot % 2 != a[i]:
            print(-1)
            return

    res = []
    for i in range(1, n + 1):
        if b[i]:
            res.append(i)

    print(len(res))
    print(*res)




BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

Solution (Python):

N=int(input())
A = [int(i) for i in input().split()]
B = [None]*N
for i in range(N//2,N):
    B[i] = A[i]

for i in range(N//2):
    j = N//2- i 
    B[j-1] = (sum([B[k*j -1] for k in range(2,N//j+1)]) - A[j-1]) %2
ans = [k+1 for k in range(N) if B[k]]
print(len(ans))
print(*ans)

Solution (Python):
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)

Solution (Python):
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = [0] + list(map(int, sys.stdin.readline().split()))

divs = [[] for _ in range(N + 1)]
for i in range(1, N + 1):
    n = i
    while n + i <= N:
        n += i
        divs[n].append(i)
ans = [0] * (N + 1)
for i in reversed(range(1, N + 1)):
    ans[i] += A[i]
    ans[i] %= 2
    if ans[i]:
        for d in divs[i]:
            ans[d] += 1
            ans[d] %= 2

nums = []
for i, a in enumerate(ans[1:]):
    if a:
        nums.append(i + 1)
print(len(nums))
print(*nums)

Solution (Python):
N = int(input())

a = list(map(int,input().split()))

ball = [-1 for i in range(N)]

for i in range(N):
    num=N-i
    s = 0
    for i in range(N//num):
        if ball[(N//num - i)*num-1]!=-1:
            s+=ball[(N//num - i)*num-1]
        else:
            ball[(N//num - i)*num-1]=(a[num-1]-s)%2
ans = []
for i in range(N):
    if ball[i]==1:
        ans.append(i+1)

print(len(ans))
if len(ans)!=0:
    print(*ans)

Solution (Python):
from collections import defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 5 + 10)

import math



def main():
    num = int(input())
    data = list(map(int, input().split()))

    ans_data = [-1 for i in range(num + 1)]
    
    for i in range(1, num + 1)[::-1]:
        count = 0
        ind = i * 2
        while ind <= num:
            if ans_data[ind]:
                count ^= 1
            ind += i
        
        ans_data[i] = data[i - 1] ^ count

    count = 0
    for i in range(1, num + 1):
        if ans_data[i]:
            count += 1

    print(count)

    for i in range(1, num + 1):
        if ans_data[i]:
            print(i)




if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split(" ")))

b = [0]*(n+1)
for i in range(n, 0, -1):
    count = 0
    j = i
    while j <= n:
        count += b[j]
        j += i
    if count%2 != a[i-1]:
        b[i] = 1

print(sum(b))
ans = []
for i in range(n):
    if b[i+1] == 1:
        ans.append(i+1)

if len(ans) > 0:
    for i in range(len(ans)-1):
        print(ans[i], end=" ")
    print(ans[-1])

Solution (Python):
N=int(input())
A=list(map(int,input().strip().split(' ')))
A=[0]+A
dp=[0]*len(A)
dp[N]=A[N]
for i in range(N-1,0,-1):
    temp=0
    for j in range(2,len(A)):
        if i*j>=len(A):
            break
        temp+=dp[j*i]
    
    dp[i]=(A[i]-temp)%2
ans=sum(dp[1:])
want=[]
for i in range(len(dp)):
    if dp[i]>0:
        want+=[i]

print(ans)
if ans>0:
    print(*want)

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
aa = inpl()


n = N
ans = [0]*(N+1)
cnts = [0]*(N+1)

for a in reversed(aa):
    
    if cnts[n]%2 == a:
        ans[n] = 0
    else:
        ans[n] = 1
        r = 1
        while r <= math.sqrt(n):
            if n%r == 0:
                cnts[r] += 1
                if r != n//r:
                    cnts[n//r] += 1
            r += 1
    n -= 1


tmp = sum(ans)
if tmp == 0:
    print(0)
else:
    print(tmp)
    fans = []
    for i,x in enumerate(ans):
        if x == 1:
            fans.append(str(i))
    print(' '.join(fans))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = [0] * n

for i in reversed(range(1, n+1)):
    count = 0
    for j in range(2, n+1):
        if i * j > n:
            break
        count += b[i*j-1]
    if count % 2 == a[i-1]:
        b[i-1] = 0
    else:
        b[i-1] = 1

ans = 0
box = []
for i in range(n):
    if b[i]:
        ans += 1
        box.append(i+1)

print(ans)
print(*box)

Solution (Python):
N = int(input())
As = list(map(int, input().split()))

isBalls = [0] * (N+1)
for k in reversed(range(1, N+1)):
    num = sum([isBalls[k*i] for i in range(1, N//k+1)])
    if num % 2 != As[k-1]:
        isBalls[k] = 1

M = sum(isBalls)
anss = [i for i in range(1, N+1) if isBalls[i] > 0]

print(M)
print(' '.join(map(str, anss)))

Solution (Python):
n = int(input())
alist = list(map(int, input().split()))
boxList = [0] * (n + 1)

m = 0
resultList = []

for i in range(1, n+1)[::-1]:
    sums = 0
    for j in range(1, n // i):
        sums += boxList[(j+1) * i]
    if sums % 2 != alist[i - 1]:
        boxList[i] = 1
        m+= 1
        resultList.append(i)

print(m)
if m != 0:
    print(' '.join(map(str, resultList)))

Solution (Python):
N=int(input())
A=[0]+list(map(int,input().split()))

ANS=[0]*(N+1)

for i in range(N,0,-1):
    SUM=0
    for j in range(i*2,N+1,i):
        SUM=(SUM+ANS[j])%2

    ANS[i]=(A[i]-SUM)%2

if min(ANS)<0 or max(ANS)>1:
    print(-1)
else:
    ANS2=[i for i in range(N+1) if ANS[i]==1]
    print(len(ANS2))
    print(*ANS2)

Solution (Python):



import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]

ans = [0]*n

for i in range(n-1,-1,-1):
    ai = a[i]
    j = i+1
    while i < n:
        if ans[i]: ai ^= 1
        i += j
    ans[j-1] = ai



res = [i+1 for i,c in enumerate(ans) if c]

print(len(res))
print(*res)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n = I()
    print(3*n**2)
    return


def B():
    n,d = LI()
    f = [1]*(n+2*d+2)
    ans = 0
    for i in range(n):
        if f[i]:
            for j in range(i,i+2*d+1):
                f[j] = 0
            ans += 1
    print(ans)
    return


def C():
    n = I()
    a = IR(n)
    mi = max(a)
    if a.count(mi) > 1:
        for i in range(n):
            print(mi)
    else:
        b = [a[i] for i in range(n)]
        b.sort()
        b = b[::-1]
        for i in range(n):
            if mi != a[i]:
                print(mi)
            else:
                print(b[1])

    return


def D():
    n = I()
    a = LI()
    b = [0]*(n+1)
    for i in range(1,n+1)[::-1]:
        j = 2*i
        k = 0
        while j <= n:
            k ^= b[j]
            j += i
        if a[i-1]^k:
            b[i] = 1
    ans = []
    for i in range(n+1):
        if b[i]:
            ans.append(i)
    print(len(ans))
    if ans:
        print(*ans)
    return


def E():
    n = I()

    return


def F():
    n = I()

    return


if __name__ == "__main__":
    D()

Solution (Python):
def div(val):
  ret=[]
  for i in range(1,int(val**0.5)+1):
    if val%i==0:
      ret.append(i)
      if val//i!=i:
        ret.append(val//i)
  return ret

n=int(input())
arr=list(map(int,input().split()))
cnt=[0]*n
num=0
ans=[]
for i in range(n-1,-1,-1):
  if (arr[i]+cnt[i])%2==0:
    continue
  else:
    ans.append(i+1)
    num+=1
    for j in div(i+1):
      cnt[j-1]+=1
if num==0:
  print(0)
else:
  print(num)
  print(*ans)

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))

res = [0] * (n + 1)

for i in range(1, n + 1)[::-1]:
    sum_res = sum(res[x] for x in range(i, n + 1, i))
    if sum_res % 2 != arr[i - 1]:
        res[i] = 1

print(sum(res))

if sum(res):
    ans = []
    for i, ele in enumerate(res):
        if ele:
            ans.append(i)
    print(*ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

ans = set()

for i in range(N-1,-1,-1):
    a = A[i]
    for j in range(i+1,N+1,i+1):
        if j in ans:
            a += 1
    if a%2:
        ans.add(i+1)

print(len(ans))
print(*ans)

Solution (Python):
def main():
    n = input()
    aa = map(int, raw_input().split())
    ans = [0] * n
    m = 0
    for i in xrange((n + 1) // 2, n):
        if aa[i] == 1:
            ans[i] = 1
            m += 1
    for i in xrange((n + 1) // 2 - 1, -1, -1):
        s = sum(ans[i::i + 1]) % 2
        if aa[i] != s:
            ans[i] = 1
            m += 1
    print m
    for i, a in enumerate(ans, 1):
        if a:
            print i


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
A=tuple(map(int,input().split()))
B=[0]*n
for i in reversed(range(n//2,n)):
    B[i]=A[i]
for i in reversed(range(n//2)):
    k=i+1
    l=n//k
    tmp=0
    for j in range(2,l+1):
        idx=k*j-1
        tmp+=B[idx]
    B[i]=(tmp%2-A[i])%2
s=0
Ans=[]
for i,b in enumerate(B):
    if b:
        s+=1
        Ans.append(i+1)
print(s)
print(*Ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

b = [0 for _ in range(N + 1)]
M = 0
for i in range(N, 0, -1):
    x = a[i - 1]
    for j in range(i, N + 1, i):
        x += b[j]
    x = x % 2
    b[i] = x
    M += x
print(M)
for i in range(1, N + 1):
    if b[i] == 1:
        print(i)

Solution (Python):
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]])

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

ans = [0] * N

for i in range(N, 0, -1):
  t = 0
  for j in range(i + i, N + 1, i):
    t += ans[j - 1]
  k = t % 2
  if a[i - 1] != k:
    ans[i - 1] = 1

L = []
su = 0
for i in range(N):
  if ans[i] == 1:
    su += 1
    L.append(i + 1)

print(su)
if len(L) != 0:
  print(" ".join(map(str, L)))

Solution (Python):
N = int(input())
A = [None] + list(map(int, input().split()))

dp = [None]*(N+1)
for i in range(N, 0, -1):
    a = A[i]
    for j in range(2*i, N+1, i):
        a -= dp[j]
    dp[i] = (a % 2)
dp = dp[1:]
print(sum(dp))
for i in range(N):
    if dp[i]:
        print(i+1)

Solution (Python):
N = int(input())
a_list = list(map(int, input().split()))
res_list = [0] * N

for i in range(N - 1, -1, -1):
    r = sum(res_list[i::(i + 1)])
    if (r - a_list[i]) % 2 != 0:
        res_list[i] = 1

S = sum(res_list)
print(S)

if S != 0:
    print(" ".join([str(i+1) for i in range(N) if res_list[i] == 1]))

Solution (Python):
import sys


fin = sys.stdin.readline
N = int(fin())
a_list = [int(elem) for elem in fin().split()]
is_ball_in = [False] * N
for i in reversed(range(1, N + 1)):
    num_balls = 0
    for j in range(i, N + 1, i):
        num_balls += is_ball_in[j - 1]
    num_balls %= 2
    a = a_list[i - 1]
    if num_balls != a:
        is_ball_in[i - 1] = True
    else:
        is_ball_in[i - 1] = False

num_boxes_with_a_ball = sum(is_ball_in)
print(num_boxes_with_a_ball)
indices = [i for i, b in enumerate(is_ball_in, start=1) if b]
print(*indices)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

ans = [0]*N
for i in reversed(range(1,N+1)):
    v = A[i-1]
    for j in range(i,N+1,i):
        v += ans[j-1]
    ans[i-1] = v % 2

M = sum(ans)
print(M)
if M:
    print(*(i+1 for i,b in enumerate(ans) if b == 1))

Solution (Python):
from collections import *
import sys
inp = raw_input

def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]

N = ni()
A = nl()

out = [0]*N
fail = False
B = []
for i in range(N-1, -1, -1):
    j = i + 1
    S = 0
    for k in range(i, N, j):
        S += out[k]
    if S%2 != A[i]:
        out[i] = 1
        B.append(j)
print(len(B))
if len(B):
    print(' '.join(map(str, B)))

Solution (Python):
N=int(input())
a=[-1]+[int(i) for i in input().split()]
b=[0 for i in range(N+1)]
for i in range(1,N+1)[::-1]:
    tmp=0
    for j in range(2*i,N+1,i):
        tmp+=b[j]
    if tmp%2!=a[i]:
        b[i]=1
ans=[]
for i in range(N+1):
    if b[i]==1:
        ans.append(str(i))
print(len(ans))
print(" ".join(ans))