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


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


def main():
    n = int(input())
    bits = [int(e) for e in 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)


main()

Solution (Python):
N = int(input())
A = [int(_) for _ in input().split()]

ans_lis = [0] * N
to_print_lis = []

for n in range(N - 1, -1, -1):
    sum_lis = sum(A[n: : n + 1])
    tmp_lis = ans_lis[n: : n + 1]
    if sum(tmp_lis) % 2 != A[n]:
        ans_lis[n] = 1
        to_print_lis.append(n + 1)
    
print(len(to_print_lis))
print(*to_print_lis)

Solution (Python):
m = int(input())
s = list(map(int, input().split()))
bs = [0] * m

cnt = 0
for i in range(m, 0, -1):
  b = sum(list(map(lambda x: bs[x-1], list(range(i, m+1, i)))))
  if s[i-1] is 0:
    if  b%2 is 0:
      bs[i-1] = 0
    else:
      cnt += 1
      bs[i-1] = 1
  else:
    if  b%2 is 0:
      cnt += 1
      bs[i-1] = 1
    else:
      bs[i-1] = 0

print(cnt)
if cnt > 0:
  print(" ".join([str(i+1) for i, b in enumerate(bs) if b > 0]))

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

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math






def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    
    ans = [0]*N
    B=[]
    ans_str = ""
    for i in range(N, 0, -1):
        cons = 0
        for j in range(i, N+1, i):
            if ans[j-1] == 1:
                cons += 1
        if A[i-1] == 1 and cons % 2 == 0:
            ans[i-1] = 1
            B.append(i)
            continue
        if A[i-1] == 0 and cons % 2 == 1:
            ans[i-1] = 1
            B.append(i)
            continue
            
    print(len(B))
    print(*B)
            	
if __name__ == "__main__":
	main()

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math






def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    
    ans = [0]*N
    B=[]
    ans_str = ""
    for i in range(N, 0, -1):
        cons = 0
        for j in range(i, N+1, i):
            if ans[j-1] == 1:
                cons += 1
        if A[i-1] == 1 and cons % 2 == 0:
            ans[i-1] = 1
            B.append(i)
            
            continue
        if A[i-1] == 0 and cons % 2 == 1:
            ans[i-1] = 1
            B.append(i)
            
            continue
            
    print(len(B))
    print(*B)
            	
if __name__ == "__main__":
	main()

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math






def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    
    ans = [0]*N
    B=[]
    for i in range(N, 0, -1):
        cons = 0
        for j in range(i, N+1, i):
            if ans[j-1] == 1:
                cons += 1
        if A[i-1] == 1 and cons % 2 == 0:
            ans[i-1] = 1
            B.append(i)
            continue
        if A[i-1] == 0 and cons % 2 == 1:
            ans[i-1] = 1
            B.append(i)
            continue
            
    print(len(B))
    print(*B)
            	
if __name__ == "__main__":
	main()

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math






def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    
    ans = [0]*N
    B=[]
    for i in range(N, 0, -1):
        cons = 0
        for j in range(i, N+1, i):
            cons ^= ans[j-1]
        if A[i-1] != cons:
            ans[i-1] = 1
            B.append(i)
            continue
        if A[i-1] != cons:
            ans[i-1] = 1
            B.append(i)
            continue
            
    print(len(B))
    print(*B)
            	
if __name__ == "__main__":
	main()

Solution (Python):
import sys
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
 
N=INT()
A=LIST()
 

A2=[0]*N
B=[]

for i in range(N-1, -1, -1):
    cur=i+1
    cnt=0
    
    for j in range(cur*2, N+1, cur):
        cnt^=A2[j-1]
    
    if A[i]!=cnt:
        B.append(cur)
        A2[i]=1
 
print(len(B))
print(*B)

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

for i in range(N-1,-1,-1):
    A[i] = sum(A[i::i+1]) % 2

s = sum(A[0:N])
print(s)

n = 1
for i in range(N):
    if A[i] == 1:
        if n == s:
            print(i+1)
            break
        else:
            print(i+1,end=' ')
            n += 1

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()


A2=[0]*N
B=[]

for i in range(N-1, -1, -1):
    cur=i+1
    cnt=0
    
    for j in range(cur*2, N+1, cur):
        cnt^=A2[j-1]
    
    if A[i]!=cnt:
        B.append(cur)
        A2[i]=1

print(len(B))
print(*B)

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

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

for k in range(0, n):
    if b[k] == 1:
        l.append(k+1)

print(len(l))
for m in l:
    print(m)

Solution (Python):
N = int(input())
a = [int(x) for x in input().split()]
ans = []
li = [0]*N
x = 0
for ind,i in enumerate(a[N//2:]):
    if(i==1):
        ans.append(ind+1+N//2)
        li[ind+N//2] = 1
for ind,i in enumerate(a[:N//2][::-1]):
    n = N//2-ind
    if(sum(li[n-1::n])%2!=i):
        li[n-1]=1
        ans.append(n)
ans.sort()
print(len(ans))
if(len(ans)!=0):
    print(*ans)

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



dps = [False for _ in range(N + 1)]

ans =[]

fs = N // 2
for i in reversed(range(1, N + 1)):
    d_index = i * 2
    current_sum = 0
    while d_index <= N:
        if dps[d_index]:
            current_sum += 1
        d_index += i

    if current_sum % 2 == A[i-1]:
        dps[i] = False
    else:
        dps[i] = True


ans=[]
for i in range(1, N+1):
    if dps[i]:
        ans.append(i)


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

Solution (Python):
N = int(input())
x = [0]*N
aList = [int(x) for x in input().split()]

for i in range(N,0,-1):
    a = aList[i-1]
    b = 2
    c = 0
    while (i*b) - 1 < N:
        if x[(i*b)-1] == 1:
            c += 1
        b+=1
    x[i-1] = int(c%2==0 if a == 1 else c%2==1)


print(sum(x))
for i,y in enumerate(x):
    if y == 1:
        print(i+1, end=' ')

Solution (Python):
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]
for i in range(1,N+1):
    n=N+1-i
    cnt=0
    
    for j in range(1,2*10**5+1):
        
        if n*j>N:
            break
        else:
            if B[n*j]==1:
                cnt+=1
    if cnt%2!=A[n]%2:
        B[n]=1
        ans.append(n)
ans.sort()
print(len(ans))
print(*ans)

Solution (Python):
M=0
N=int(input())
A=list(map(int,input().split()))
A.insert(0,0)
B=[]
D=[0 for i in range(N+1)]
for i in range(N):
  i=N-i
  su=0
  for j in range(i+i,N+1,i):
    su=su^D[j]
  if su!=A[i]:
    B.append(str(i))
    M=M+1
    D[i]=1
  

C=[]
for i in range(len(B)):
  i=len(B)-i-1
  C.append(B[i])
print(M)
print(" ".join(C))

Solution (Python):
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]
for i in range(1,N+1):
    
    n=N+1-i
    cnt=0
    for j in range(1,N+1):
        
        if j*n>N:
            break
        if B[j*n]==1:
            cnt+=1
    if A[n]%2!=cnt%2:
        B[n]=1
        ans.append(n)
print(len(ans))
ans.sort()
print(*ans)

Solution (Python):
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]
for i in range(1,N+1)[::-1]:
    
    cnt=0
    for j in range(1,N+1):
        
        if j*i>N:
            break
        if B[j*i]==1:
            cnt+=1
    if A[i]%2!=cnt%2:
        B[i]=1
        ans.append(i)
print(len(ans))
ans.sort()
print(*ans)

Solution (Python):
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]
for i in range(1,N+1)[::-1]:
    
    cnt=0
    for j in range(2*i,N+1,i):
        
        if B[j]==1:
            cnt+=1
    if A[i]%2!=cnt%2:
        B[i]=1
        ans.append(i)
print(len(ans))
ans.sort()
print(*ans)

Solution (Python):
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]
for i in range(1,N+1)[::-1]:
    
    cnt=0
    for j in range(i,N+1,i):
        
        if B[j]==1:
            cnt+=1
    if A[i]%2!=cnt%2:
        B[i]=1
        ans.append(i)
print(len(ans))
ans.sort()
print(*ans)

Solution (Python):
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))
for i in range(1, n + 1):
    if a[i] == 1:
        print(i)

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

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
l1=[0 for i in range(n)]
for i in range(1,1+(n+1)//2):
  if l[-i]==1:
    l1[-i]=1
  else:
    pass
for i in range((n+1)//2-1,-1,-1):
  s=0
  for j in range(2,n//(1+i)+1):
    if l1[(i+1)*j-1]==1:
      s+=1
  if s%2==1:
    if l[i]==0:
      l1[i]=1
  else:
    if l[i]==1:
      l1[i]=1
l2=[]
s=0
for i in range(n):
  if l1[i]==1:
    s+=1
    l2.append(str(i+1))
print(s)
print(" ".join(l2))

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

Solution (Python):
import math
N = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(N + 1)]
for i in range(N, N // 2, -1):
    b[i] = a[i - 1]
for i in range(N // 2, 0, -1):
    bi = a[i - 1]
    for j in range(2, N // i + 1):
        bi = bi ^ b[i * j]
    b[i] = bi
print(sum(b))
for i, j in enumerate(b):
    if j == 1:
        print(i, end = ' ')

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

a = [0] + a
b = [0 for i in range(N+1)]
i = N
while i > 0:
    s = sum(b[i::i])
    if a[i] != s % 2:
        b[i] = 1
    i -= 1

print(sum(b))
for i, j in enumerate(b):
    if j == 1:
        print(i, end=' ')

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

Solution (Python):
import math

anser=0
count=0
n  = int(input())
a = list(map(int, input().split()))
data  = []
result =[]



for i in range(n,0, -1):
	try:
		for s in range (2,math.floor(n/(i)+1)):
			count += data[-i*(s-1)]
	except IndexError:
		count = 0 
	data.append((count+a[i-1])%2)
	anser+=(count+a[i-1])%2
	count=0


print(anser)
if anser!=0:
	for i ,j in enumerate(data[::-1]):
		if j ==1:
			result.append(i+1)
	print(' '.join(list(map(str, result))))

Solution (Python):
N = int(input())
a = [0]+list(map(int, input().split()))
box = [None]+[0]*(N)
cnt = 0
   
for i in range(N, 0, -1):
    mult = [j for j in range(i,N+1,i)]
    sm = 0
    for m in mult:
        if box[m]:
            sm += 1
    if sm%2 != a[i]:
        box[i] = 1
        cnt += 1
        
print(cnt)        
print(" ".join(map(str,[i for i,b in enumerate(box) if b])))

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):

import sys
input = sys.stdin.readline
def main():
    n = int(input())
    A = [0] + list(int(i) for i in input().split())
    for i in range(n//2,0,-1):
        A[i] = sum(A[i::i]) % 2
    ans = [i for i, j in enumerate(A) if j]
    print(len(ans))
    print(*ans)
 
 
if __name__ == "__main__":
    main()

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

ball = [0] * (n + 1)
for i in reversed(range(1, n + 1)):
    if a[i] == 1:
        if sum(ball[i * 2::i]) % 2 == 0:
            ball[i] = 1
        else:
            ball[i] = 0
    else:
        if sum(ball[i * 2::i]) % 2 == 0:
            ball[i] = 0
        else:
            ball[i] = 1

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

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

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

a = [0]

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

result = [0] * (N+1)
numbers = []

for i in range(N, 0, -1):
    sum = 0

    for j in range(2*i, N+1, i):
        sum += result[j]

    if (a[i] - sum) % 2 == 0:
        result[i] = 0
    else:
        result[i] = 1
        numbers.append(i)

print(len(numbers))

for number in numbers:
    print(number, end=" ")

Solution (Python):
n = int(input())
A = [int(s) for s in input().split()]
cen = n //2
ANS = [0]*(cen)
A_p = A[cen:n]
ANS = ANS + A_p

for i in range(cen):
    part_sum = sum(ANS[cen-i-1::cen-i])
    dot = part_sum % 2
    if dot == A[cen-i-1]:
        pass
    else:
        ANS[cen-i-1] = 1

sum_ans = sum(ANS)
print(sum_ans)
if sum_ans == 0:
    pass
else:
    B = []
    for i in range(n):
        if ANS[i] != 0:
            B.append(str (i+1))
        else:
            pass
    B =" ".join(B)
    print(B)

Solution (Python):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
  
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  ans = [0]*n
  for i in range(n-1,-1,-1):
    if a[i] == 0:
      continue
    else:
      ans[i] = 1
      tmp = i+1
      div = make_divisors(tmp)
      
      for j in div:
        a[j-1] = 1^a[j-1]
        
  print(sum(ans))
  for i in range(len(ans)):
    if ans[i] == 1:
      print(i+1,end = " ")
solve()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = [ 0 for _ in range(N+1) ]
ans = []
for i in range(1, N+1)[::-1]:
  c = 0
  for j in range(i, N+1, i):
    if B[j]:
      c += 1
  if c % 2 == A[i-1]:
    B[i] = 0
  else:
    B[i] = 1
    ans.append(i)
ans.sort()
print(len(ans))
print(" ".join([ str(x) for x in ans]))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0 
index = [] 

for i in range(n-1, -1, -1):
    balls = 0
    j = i
    while j +(i+1) < n:
        j += i + 1
        balls += ball[j]
    
    if a[i] != balls%2:
        ball[i] = 1
        count += 1
        index.append(i+1)
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

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

N = int(input())
L = [int(v) for v in input().split()]

s = {}
for i in reversed(range(N)):
    c = i + 1

    p = 0
    for v in range(c, N + 1, c):
        if s.get(v) == 1:
            p += 1

    if p % 2 != L[i]:
        s[c] = 1

t = list(s.keys())

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

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

M=0
for i in range(N,0,-1):
	sum = 0
	for j in range(i*2,N+1,i):
		sum += Bi[j-1]
	if sum % 2 == Ai[i-1]:
		Bi[i-1] = 0
	else:
		Bi[i-1] = 1
		M += 1

print(M)
for i in range(N):
	if Bi[i] == 1:
		print(i+1)

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

ans = [0]*n

for i in reversed(range(n)):
  j = i+1
  b = 0
  while j <= n:
    b += ans[j-1]
    j += i+1
  if b%2 != l[i]:
    ans[i] = 1

print(sum(ans))
print(' '.join(map(str, [i+1 for i, x in enumerate(ans) if x!= 0])))

Solution (Python):
n = int(input())
a = [-1]+list(map(int, input().split()))
cnt = n//2
b = [-1]+[0] *(n//2)+a[n//2+1:]

for i in reversed(range(1,n//2+1)):
    b[i] = abs((sum([b[i*j] for j in range(2,n//i+1)])%2) - a[i])

m = len([b[i] for i in range(n+1) if b[i] == 1])
bb = list(map(str,[i for i in range(n+1) if b[i] == 1]))
print(m)
print(" ".join(bb))

Solution (Python):


import numpy as np

N = int(input())

A = list(map(int,input().split()))
B = A
ct = 0

for i in range(N):
    j = N-i-1
    if(j+1>N/2):
        B[j] = A[j]
        
        if(B[j]==1):
            ct = ct + 1
    else:
        sum = 0
        for k in range(j+1,N+1,j+1):
            if(k%(j+1)==0 and k!=j+1):
                
                sum = sum + B[k-1]
        if(sum%2==0):
            B[j] = A[j]
            if(B[j]==1):
                ct = ct + 1
        else:
            B[j] = 1 - A[j]
            
            if(B[j]==1):
                ct = ct + 1
        

print(ct)
C = []

for i in range(N):
    if(B[i]==1):
        C.append(i+1)
print(*C)

Solution (Python):
n=int(input())
info=list(map(int,input().split()))
info.insert(0,0)
box=[0]*(n+1)
ball=0
num=[] 
for i in range(n,0,-1):
    j=i
    total=0
    while j<=n:
        total+=box[j]
        j+=i
    if total%2!=info[i]: 
        box[i]=1
        ball+=1
        num.append(i)

print(ball)
if ball!=0:
    l=len(num)
    for i in range(l):
        print(num[i],end=" ")

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

b = [0 for i in range(N)]

for i in range(N)[::-1]:
    s = N // (i+1)
    a = a_list[i]
    if s > 1:
        m_a = sum([b[(i+1)*k-1] for k in range(2, s+1)]) % 2
        a = a ^ m_a
    b[i] = a
print(sum(b))

res = ""
for i in range(len(b)):
    if b[i] > 0:
        res += str(i+1) + " "
if len(res) > 0:
    print(res)

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

num = len(a)
b = [0] * num

for i in reversed(range(1, num+1)):
    index = list(range(i, num+1, i))
    
    count = 0
    for s in index:
        count += b[s-1]
    

    if a[i-1] != count % 2:
        b[i-1] = 1

if max(b) == 0:
    print(0)
else:
    s = []
    for i, x in enumerate(b):
        if x == 1:
            s.append(i+1)
    print(len(s))
    print(" ".join(map(str, s)))

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):
import sys

inf = 10 ** 18
P = 10 ** 9 + 7

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

x = [ai % 2 for ai in a]
for i_inv in range(N):
    i = (N - 1) - i_inv
    j = 2
    xi = x[i]
    
    while (i + 1) * j - 1 < N:
        
        xi ^= x[(i + 1) * j - 1]
        j += 1
    x[i] = xi

print(sum(x))
ans = []
for i, xi in enumerate(x):
    if xi == 1:
        ans.append(i + 1)

if sum(x) > 0:
    print(' '.join(map(str, ans)))

Solution (Python):
from operator import xor

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


def multiples(n, m):
    
    lst = list()
    num = n
    while True:
        if num <= m:
            lst.append(num)
            num += n
        else:
            break
    return lst


ans = [0] * (N + 1)
for i in reversed(range(1, N + 1)):
    s = 0
    for m in multiples(i, N):
        s += ans[m]
    s %= 2
    ans[i] = xor(s, A[i - 1])

s = sum(ans)
print(s)
if s != 0:
    print(' '.join([str(i) for i in range(1, N + 1) if ans[i] > 0]))

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):
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (n + 1)

for i in range(n, 0, -1):
    x = 0
    for j in range(i, n + 1, i):
        x ^= b[j]
    if x != a[i]:
        b[i] = 1

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

Solution (Python):
n = int(input())
a_array = [int(x) for x in input().split()]
ans_array = [0 for x in range(n)]
for index in reversed(range(1, n + 1)):
    if index > n // 2:
        ans_array[index - 1] = a_array[index - 1]
    elif index - 1 != 0:
        tmp = sum([ans_array[x] for x in range(index * 2 - 1, n, index) if ans_array[x] != 0]) % 2
        if tmp == a_array[index - 1]:
            pass
        else:
            ans_array[index - 1] = 1

    else:
        tmp = sum([x for x in ans_array[1:] if x != 0]) % 2
        if tmp == a_array[index - 1]:
            pass
        else:
            
            ans_array[index - 1] = 1
print(sum([x for x in ans_array if x != 0]))
for index, ans in enumerate(ans_array, 1):
    if ans != 0:
        print(index)

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

a = [0] + [int(i) for i in input().split()]
b = [0 for i in range(n+1)] 
ans = []

for i in range(n, 0, -1):
    s = 0
    for j in range(i*2, n+1, i):
        s ^= b[j]
    if s != a[i]:
        b[i] = 1
        ans.append(i)
print(len(ans))
print(' '.join(map(str, ans)))

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

c = [0] * (n+1)

for i in range(n, 0, -1):
    c[i] = a[i]
    tmp = i * 2
    while tmp <= n:
        c[i] -= c[tmp]
        tmp += i
    c[i] = c[i] % 2

print(sum(c))
for i in range(1, n+1):
    if c[i] == 1:
        print(i)

Solution (Python):
N = int(input())
L = [0] + list(map(int,input().split()))
N = len(L)
ans = [0 for i in range(N + 2)]
for i in reversed(range(1,N)):
    cnt = 0
    c = i
    while True:
        c += i
        if c > N:
            break
        cnt += ans[c]
    if cnt % 2 == 0 and L[i] == 0:
        ans[i] = 0
    elif cnt % 2 == 0 and L[i] == 1:
        ans[i] = 1
    elif cnt % 2 == 1 and L[i] == 0:
        ans[i] = 1
    else:
        ans[i] = 0 
c = 0
for i in range(len(ans)):
    if ans[i] == 1:
        c = i
ans = ans[1:c+1]

cnt = 0
for x in ans:
    if x == 1:
        cnt += 1
print(cnt)
for i in range(len(ans)):
    if ans[i] == 1:
        print(i+1,end = ' ')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
box = [0] * n
ans = []
cnt = 0
for i in reversed(range(1, n + 1)):
    for j in range(1, (n // i) + 1):
        if box[i * j - 1] == 1:
            cnt += 1
    if cnt % 2 != a[i - 1]:
        ans.append(i)
        box[i - 1] = 1
    cnt = 0

print(len(ans))
print(' '.join(map(str, ans)))

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

ans = []
for k in reversed(range(1, N + 1)):
    if a[k - 1] == 1:
        ans.append(k)
        tmp = 1
        while tmp * tmp <= k:
            if k % tmp == 0:
                a[tmp - 1] ^= 1
                if tmp != k // tmp:
                    a[k // tmp - 1] ^= 1
            tmp += 1

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
put = []

for i in reversed(range(N)):
    if A[i]:
        put.append(i+1)
        
        tmp = 1
        n = i+1
        while tmp*tmp <= n:
            if n % tmp == 0:
                A[tmp-1] ^= 1
                if tmp != n//tmp:
                    A[n//tmp-1] ^= 1
            tmp += 1


if len(put) > 0:
    print(len(put))
    print(*put)
else:
    print(0)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = [0]*N
put = []

for i in reversed(range(N)):
    if A[i] != B[i]:
        put.append(i+1)
        
        tmp = 1
        n = i+1
        while tmp*tmp <= n:
            if n % tmp == 0:
                B[tmp-1] ^= 1
                if tmp != n//tmp:
                    B[n//tmp-1] ^= 1
            tmp += 1


if len(put) > 0:
    print(len(put))
    print(*put)
else:
    print(0)

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

    b = [0] * (N + 1) 

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

main()

Solution (Python):


import sys
from math import sqrt

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def divisor_set(N: int) -> set:
    """ 約数の列挙・個数 """
    
    s = {1, N}
    
    for i in range(2, int(sqrt(N))+1):
        
        if N % i == 0:
            s.add(i)
            s.add(N // i)
    return s

N=INT()
A=LIST()

A2=[0]*N
B=[]
for i in range(N-1, -1, -1):
    if A[i]!=A2[i]:
        B.append(i+1)
        div=divisor_set(i+1)
        for num in div:
            A2[num-1]=1-A2[num-1]
        
print(len(B))
print(*B)

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

print(*ans)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys, math, bisect, random, itertools
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    n = II()
    print(n*n*3)
    return


def B():
    n, d = LI()
    print((n-1)//(2*d+1)+1)
    return


def C():
    n = II()
    a = IR(n)
    b = a[::1]
    b.sort()
    for i in range(n):
        if a[i] == b[-1]:
            print(b[-2])
        else:
            print(b[-1])
    return


def D():
    n = II()
    a = [0] + LI()
    for i in range(n // 2, 0, -1):
        x = sum(a[i::i])
        if x % 2 != a[i]:
            a[i] ^= 1
    ans = []
    x = 0
    for i in range(1, n + 1):
        if a[i]:
            ans.append(str(i))
            x += 1
    print(x)
    if x == 0:
        return
    print(" ".join(ans))
    return


def E():
    return


def F():
    return


if __name__ == '__main__':
    D()

Solution (Python):

N = int(input())
a_lst = list(map(int, input().split()))

M = 0
ans_lst = [0] * N

for i in range(N-1, -1, -1):
    if sum(ans_lst[i::i+1]) % 2 != a_lst[i]:
        ans_lst[i] = 1
    

m = sum(ans_lst)    


print(m)
ans_str = ""
for i in range(N):
    if ans_lst[i] == 1:
        ans_str += str(i+1) + " "
print(ans_str)