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):
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10




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

box = [0 for _ in range(N)]
box = [None] + box

for i in range(N, 0, -1):
    baisu_list = []
    for j in range(1, N+1):
        tmp = i * j
        if tmp > N:
            break
        else:
            baisu_list.append(tmp)

    in_list = []
    not_in_list = []

    for cur in baisu_list:
        if box[cur] == 1:
            in_list.append(cur)
        else:
            not_in_list.append(cur)

    if a[i] == len(in_list)%2:
        pass
    else:
        if not_in_list:
            box[not_in_list[0]] = 1
        else:
            print(-1)
            exit()


b = [i for i in range(1, N+1) if box[i] == 1]

print(len(b))
if b:
    print(*b, sep=" ")

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
def cal(x):
    divisors = []
    for i in range(1, int(x**0.5)+1):
        if x % i == 0:
            divisors.append(i)
            if i != x // i:
                divisors.append(x//i)
    return divisors
num=[0 for _ in range(n+1)]
cnt=0
ans=[]
for k in range(n):
    if (num[n-k]+1)%2==a[-1-k]:
        ans.append(n-k)
        cnt+=1
        l=cal(n-k)
        for p in l:
            num[p]+=1
ans1=[]
for j in range(cnt):
    if j<cnt-1:
        ans1.append(str(ans[j]))
        ans1.append(" ")
    else:
        ans1.append(str(ans[j]))
print(cnt)
if len(ans1)>0:
    result=''.join(ans1)
    print(result)

Solution (Python):
import math

N = int(input())
a_list = [-1] + list(map(int, input().split()))

b_list = [None] * (N + 1)
for i in range(N, 0, -1):
	b = a_list[i]
	for j in range(i * 2, N + 1, i):
		b = b ^ b_list[j]
	b_list[i] = b

count = 0
b_list2 = []
for i in range(1, N + 1):
	if b_list[i] == 1:
		count += 1
		b_list2.append(str(i))

print(count)
print(" ".join(b_list2))

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i - 1)
            if i != n // i:
                divisors.append(n//i - 1)

    return divisors

box = []
for i in range(n - 1, -1, -1):
    ind = make_divisors(i + 1)
    if num[i] % 2 != a[i]:
        for j in ind:
            num[j] += 1
        box.append(i + 1)
print(len(box))
print(*box)

Solution (Python):
import math


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


N = int(input())
As = list(map(int, input().split(" ")))
As = [0] + As
kosu = [0] *(N+1)

anss = []
bs  = [0] *(N+1)
for i in range(N,N//2,-1):
    if As[i] == 0:
        bs[i] =0
    else:
        bs[i] = 1

for i in range(N// 2, 0, -1):
    temp = 0
    for k in range(1,N + 1):
        if i * k > N:
            break
        if bs[i * k] == 1:
            temp += 1
    if As[i] % 2  != temp %2:
        bs[i] = 1
print(bs.count(1))
for i,num in enumerate(bs):
    if num == 1:
        print(i)

Solution (Python):


def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = A.copy()
    for i in reversed(range(1, N // 2 + 1)):
        tag = i * 2
        tmp = 0
        while tag <= N:
            tmp += ans[tag - 1]
            tag += i
        ans[i - 1] = 1 if tmp % 2 != ans[i - 1] else 0

    print(sum(ans))
    s = ''
    for i, a in enumerate(ans, 1):
        if a == 1:
            s += str(i) + ' '
    if s != '':
        print(s.strip())


if __name__ == '__main__':
    solve()

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



fail = False
r = [0 for i in range(N)]
for i in range(N)[::-1]:
  tmpsum = 0
  for t in range(2,(N//(i+1))+1):

    tmpsum += r[(i+1)*t-1]
  diff = (a[i]-tmpsum)%2

  if diff == 1:
    r[i] = 1
  elif diff == 0:
    r[i] = 0
  else:
    fail = True
    break

if fail:
  print(-1)
else:
  print(sum(r))


  result = []
  for i in range(N):
    if r[i]==1:
      result.append(i+1)
  if len(result) > 0:
    print(" ".join(map(str,result)))

Solution (Python):
import numpy as np

n = int(input())

a = [int(i) for i in input().split()]
a = np.array(a)
b = np.zeros(n)
b_ind = np.arange(1, n + 1)
b[n // 2 + 1:] = a[n // 2 + 1:]

for i in range(n // 2 + 1, 0, -1):
    if np.sum(b[i - 1::i]) % 2 == a[i - 1]:
        b[i - 1] = 0
    else:
        b[i - 1] = 1

m = b[b == 1].shape[0]
print(m)
if m != 0:
    print(" ".join(map(str, b_ind[b == 1])))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = [0 for _ in range(N)]
half = int(N / 2) + 1
s = 0
hako = []



for i in reversed(range(N)):
    if i+1 >= half:
        if A[i] == 1:
            ans[i] = 1
            s += 1
            hako.append(i+1)
    else:
        cur = (i+1)*2
        tmp = 0
        while cur <= N:
            if ans[cur-1] == 1:
                tmp += 1
            cur += i+1
        if tmp % 2 != A[i]:
            ans[i] = 1
            s += 1
            hako.append(i+1)

print(s)
if len(hako) > 0:
    print(*hako)

Solution (Python):
N =int(input())
As = [int(x) for x in input().split()]
res = [0]*(N)
ks = range(N)

for i in range(N-1,N//2,-1):
    res[i] = As[i]
for i in range(N//2,0,-1):
    res[i] = (As[i]+sum(res[i::(i+1)]))%2
res[0] = (As[0]+sum(res[1:]))%2
ans =[]
for i,v in enumerate(res):
    if v==1:
        ans.append(i+1)
print(len(ans))
print(" ".join(map(str,ans)))

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

INPUT_L = [0] + A[:]
B = [0] * (N+1)


for i in range(N//2+1, N+1):
    B[i] = INPUT_L[i]
    
for i in reversed(range(1, N//2+1)):
    
    
    sum_b = sum(B[i::i])
    if sum_b % 2 == INPUT_L[i]:
        continue
    else:
        B[i] = 1
    
ans_sum = sum(B)

if ans_sum % 2 != INPUT_L[1]:
    print(-1)
else:
    
    ans_list = []
    for i, b in reversed(list(enumerate(B))):
        if b != 0:
            ans_list.append(str(i))

    print(ans_sum)
    print(' '.join(ans_list))

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

N = int(input())
a = [0]+[int(i) for i in input().split()]
ret = [0] * (N+1)

def rec(i) :
    if i == N + 1 :
        return
    rec(i+1)
    s = 0
    for j in range(i, N + 1, i) :
        s ^= ret[j]
    ret[i] = s^a[i]
    
rec(1)
b = []
for i in range(1, N + 1) :
    if ret[i] :
        b.append(str(i))
print(len(b))
print(' '.join(b))

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]
b = [0] * n

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

ans = 0
ANS = []
for i in range(n):
    if(b[i] == 1):
        ans += 1
        ANS.append(i)
print(ans)
for i in range(len(ANS)):
    print(ANS[i]+1, end=' ')

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


B = [0]*N

for i in range(N//2 + 1, N + 1):

    B[i - 1] = A[i - 1]

for i in range(N // 2):
    index = N // 2 - i - 1
    num = 0

    for j in range(1, N // (index + 1) + 1):
        v = j * (index + 1) - 1
        num += B[v]
        

    if num % 2 != A[index]:
        B[index] = 1


M = 0
for b in B:
    if b == 1:
        M += 1
print(M)
ANS = []
for i in range(N):
    if B[i] == 1:
        ANS.append(str(i + 1))
if M > 0:
    ans = ' '.join(ANS)
    print(ans)

Solution (Python):
N = int(input())
a = [int(x) for x in input().split()]
isball = [0]*N
ball_list = []
oddeven = 0
for i in reversed(range(1, N)):
    ball_sum = 0
    for j in range(1, N // (i + 1)+1):
        ball_sum += isball[((j) * (i+1))-1]
    if ball_sum % 2 != a[i]:
        ball_list.append(i + 1)
        isball[i] = 1
        oddeven += 1

if oddeven % 2 != a[0]:
    ball_list.append(1)

print(len(ball_list))
print(*ball_list)

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
b = [0]*(N+1)


def func1(lst, value):
    return [i for i, x in enumerate(lst) if x == value]

for i in range(N,0,-1):
    
    
    b[i] = a[i]^(sum(b[i::i])%2)
    

print(sum(b[1:]))
idx = func1(b,1)
print(*idx)

Solution (Python):
import sys
import math

input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
ans = [0]*N
for i in range(N-1,-1,-1):
    if i > N//2 - 1:
        ans[i] = a[i]
    else:
        sm = 0
        for j in range(i+i+1, N, i+1):
            sm += ans[j]
        if sm % 2 == a[i]:
            ans[i] = 0
        else:
            ans[i] = 1

out = ''
for i in range(N):
    if ans[i] == 1:
        out += str(i+1) + ' '
print(ans.count(1))
print(out)

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]
def mi(n): return [wi() for _ in range(n)]
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n = i()
a = [0] + wi()
listb = []
zo = [0] * (n + 1)
re = 1
for i in range(n, 0, -1):
    re = 2
    s = 0
    while True:
        if i * re > n:
            re -= 1
            if (s + a[i]) % 2 == 1:
                listb.append(i)
                zo[i] = 1
            break
        else:
            s += zo[i * re]
            re += 1

print(len(listb))
for i in range(len(listb)):
    print(listb[-i-1])

Solution (Python):

N = int(input())

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

"""
for i in range(N):

    cnt = 1
    summ = 0
    flag = True

    while (i + 1) * cnt <= N:

        summ += a[(i + 1) * cnt -1]
        cnt += 1

    if summ % 2 != a[i]:
        flag = False
        print (i+1,"はみたさない")
        break

    else:
        pass
        print (summ,a[i],"でおｋ")

if flag :
    

    

    print (sum(a))

    ans = ""

    for i in range(len(a)):
        if a[i] == 1:
            ans += str(i+1) + " "

    print (ans[:-1])

else:
    print (-1)

"""

lis = [-1] * N



for i in range(N):

    i = N-i
    cnt = 2
    summ = 0
    flag = True

    while i * cnt <= N:

        summ += lis[i * cnt -1]
        cnt += 1

    

    if a[i-1] == 0 and summ % 2 == 0:
        lis[i-1] = 0
        

    elif a[i-1] == 0 and summ % 2 == 1:
        lis[i-1] = 1

    elif a[i-1] == 1 and summ % 2 == 0:
        lis[i-1] = 1

    elif a[i-1] == 1 and summ % 2 == 1:
        lis[i-1] = 0

    if not flag:
        break

if flag:

    

    print (sum(lis))

    ans = ""

    for i in range(len(lis)):
        if lis[i] == 1:
            ans += str(i+1) + " "

    print (ans)

else:
    print (-1)

Solution (Python):
N = int(input())
nums = input().split(" ")
a = [0]
for i in range(1, N+1):
    a.append(int(nums[i-1]))

b = [0 for i in range(N+1)]
multiple_list = [[] for i in range(N+1)]
for i in range(1,N+1):
    for j in range(i, N+1, i):
        multiple_list[j].append(i)

count = 0
for i in range(N, 0, -1):
    if a[i] == 1:
        b[i] = 1
        count+=1
        for num in multiple_list[i]:
            a[num] = 1 - a[num]

print(count)
for i in range(1,N+1):
    if b[i] == 1:
        print(i, end=" ")
if count != 0:
    print()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
ans=[0]*n
for i in range(n,0,-1):
    if i*2>n:
        ans[i-1]=a[i-1]
    else:
        j=i
        k=0
        while j<=n:
            k+=ans[j-1]
            j+=i
        if k%2!=a[i-1]:
            ans[i-1]=1
m=sum(ans)
print(m)
for i in range(n):
    if ans[i]==1:
        print(i+1,end=' ')

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

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

def check(i):
    cnt = 0
    n = i
    while n <= N:
        cnt += b[n-1]
        n += i
    return cnt

for i in range(N-1,-1,-1):
    if (a[i] + check(i+1))%2 == 1:
        b[i] = 1

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

print(cnt)
L = [str(int(i)) for i in ans]
print(' '.join(L))

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]

n=I()
a=[0]+LI()
b=[0]*(n+1)
c=[0]*(n+1)
for i in range(n,0,-1):
    if c[i]!=a[i]:
        b[i]=1 
        c[i]=1-c[i]
        for j in range(2,int(i**0.5+1)):
            if i%j==0:
                c[j]=1-c[j]
                if j!=i//j: c[i//j]=1-c[i//j]
                

s=sum(b)
if s%2!=a[1]:
    b[1]=1-b[1]
s=sum(b)    
print(s)

ans=[]
for i in range(1,n+1):
    if b[i]==1:
        
        ans.append(i)
if s!=0:
    print(*ans)

Solution (Python):
import math

def main():
    N = int(input())
    A = list(map(int, input().split()))
    b = [None]*N
    
    for i in range(N, math.ceil(N/2), -1):
        b[i-1] = A[i-1]
    
    for i in range(math.ceil(N/2), 0, -1):
        s = sum([b[j-1] for j in range(2*i, N+1, i)])
        b[i-1] = (A[i-1] + s) % 2
        
    b_out = [str(i+1) for i in range(N) if b[i] == 1]
    print(sum(b))
    print(' '.join(b_out))

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
B = [0 for _ in range(N)]
s =  N//2

B[s:] = A[s:]

for i in reversed(range(s)):
  k = i+1
 


  if A[i] == sum(B[i::k])%2:
    B[i] = 0
  else:
    B[i] = 1

  
print(B.count(1))
for i in range(len(B)):
  if B[i] == 1:
      print(i+1)

Solution (Python):
n = int(input())
boxes = [0] * n
amari = list(map(lambda x: int(x), input().split()))



def box_count(boxes, c):
    counter = 0
    for i in range(0, len(boxes), c):
        if i + c - 1 < len(boxes):
            counter += boxes[i + c - 1]
    return counter % 2
        

ballbox = ''   

for i in range(n):
    if box_count(boxes, n - i) == 1:
        boxes[n - i - 1] = 1 - amari[n - i - 1]
    else:
        boxes[n - i - 1] = 0 + amari[n - i - 1]

    if boxes[n - i - 1] == 1:
        ballbox += str(n - i) + ' '

print(sum(boxes))
print(ballbox)

Solution (Python):

import sys
import math

MOD = 2  

def solve(N: int, a: "List[int]"):
    b = [0] * N
    res = []
    balls = 0
    for i in range(N-1, -1, -1):
        k = i + 1
        c = 0
        for j in range(2, N // k + 1):
            c += b[j*k-1]
        b[i] = (a[i] + c) % 2
        if b[i]:
            res.append(str(k))
            balls += 1
    print(balls)
    if balls > 0:
        print(' '.join(res))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    a = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, a)

if __name__ == '__main__':
    main()

Solution (Python):
import math

n = int(input())
a = input().split()


oku = {}
okun = 0
for i in range(int(n/2)+1, n+1):
  oku[i] = int(a[i-1])
  if int(a[i-1]) == 1:
    okun += 1
    
for i in range(int(n/2), 0, -1):
  b = 0
  for j in range(i*2, n+1, i):
    if oku[j] == 1:
      b+=1
  if b % 2 == int(a[i-1]):
    oku[i] = 0
  else:
    oku[i] = 1
    okun += 1

print(okun)
for i in range(1,n+1):
  if oku[i] == 1:
    print(i, end = " ")

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

ball_list = [0]*N

for i in range(N,0,-1):
  num_list = list(range(i,N+1,i))
  if num_list == []:
    ball_list[i-1] = a[i-1]
  else:
    sum_ = 0
    for j in num_list:
      sum_+=ball_list[j-1]
    if sum_%2 == a[i-1]:
      ball_list[i-1] = 0
    elif (sum_+1)%2 == a[i-1]:
      ball_list[i-1] = 1
    else:
      ball_list[i-1] = -1
if -1 not in ball_list:
  ball_sum = sum(ball_list)
  if ball_sum == 0:
    print(0)
  else:
    print(ball_sum)
    ans = [str(i+1) for i, x in enumerate(ball_list) if x == 1]
    print(' '.join(ans))
else:
  print('-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)):
    if sum(b[i::i])%2 != a[i]:
        b[i] = 1

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

Solution (Python):
import copy

N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = copy.deepcopy(A)

if max(A) > 1:
	print("-1")
else:
	for i in range(N // 2, 0, -1):
		total = 0
		for j in range(2 * i, N + 1, i):
			total += B[j]
		if total % 2 != A[i]:
			B[i] = 1
		else:
			B[i] = 0
			
	print(sum(B))
	for i in range(len(B)):
		if B[i] == 1:
			print(i, end = " ")

Solution (Python):
from collections import deque
N=int(input())
A=deque(list(map(int,input().split())))
D={}
ans=[]
M=0
for i in range(N):
    a=A.pop()
    if N//(N-i)==1:
        D[N-i]=a
        if a==1:
            M+=1
            ans.append(str(N-i))
    else:
        p=N//(N-i)
        memo=0
        for j in range(1,p):
            memo+=D[(N-i)*(j+1)]
        if memo%2==a:
            D[N-i]=0
        else:
            D[N-i]=1
            M+=1
            ans.append(str(N-i))
print(M)
print(" ".join(ans))

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

Solution (Python):
import sys, math

readline = sys.stdin.readline

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

F = [0] * N
div = 2
while True:
    if N // (div - 1) == 0:
        break

    for i in range(N // (div - 1) - 1, N // div - 1, -1):
        t = A[i]
        for j in range(i * 2 + 1, N, i + 1):
            t ^= F[j]
        F[i] = t
    div += 1

M = sum(F)
print(M)

s = [str(i + 1) for i, x in enumerate(F) if x == 1]
if len(s) > 0:
    print(' '.join(s))

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

conditions = [int(x) for x in input().split(' ')]
arr = [None] * len_arr

for i in reversed(range(0, len_arr)):
    sliced_arr = arr[i::i+1]
    current_condition = sum(sliced_arr[1:]) % 2

    if current_condition == conditions[i]:
        arr[i] = 0
    else:
        arr[i] = 1


ball_indexes = [j+1 for j, ball in enumerate(arr) if ball == 1]

len_ans = len(ball_indexes)
print(len_ans)

if len_ans != 0:
    print(' '.join(map(str, ball_indexes)))

exit(0)

Solution (Python):

import sys

MOD = 2  

def solve(N: int, A: "List[int]"):
    ans = set()
    for i in range(N,0,-1):
        c = 0
        for j in range(2,N + 1):
            if i * j <= N:
                if i*j in ans:
                    c += 1
            else:
                break

        if A[i-1] == 0:
            if c % 2 == 1:
                ans.add(i)
        else:
            if c % 2 == 0:
                ans.add(i)

    print(len(ans))
    if len(ans):
        print(" ".join([str(i) for i in ans]))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    a = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, a)

if __name__ == '__main__':
    main()

Solution (Python):
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): 
	return list(map(int,input().split()))
def m(): 
	return map(int,input().split())
def onem(): 
	return int(input())
def s(x): 
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): 
	return " ".join(map(str,x))
def max2(x): 
	return max(map(max,x))

n = onem()

a = l()
k = 0
for i in range(n):
	if a[-(i+1)] == 1:
		k = n - i
		break

m = [0 for i in range(k+1)]
al = 0
for i in range(k,0,-1):
	co = 0
	if k // i < 2:
		m[i] = a[i-1]
		al += a[i-1]
	else:
		if i != 1:
			for j in range(1,k // i):
				co += m[i * (j+1)]
				co %= 2
			m[i] = (co ^ a[i-1])
			al += m[i]
		else:
			al %= 2
			m[1] = (al ^ a[0])

print(sum(m))
kkkk = []

for i in range(len(m)):
	if m[i] == 1:
		kkkk.append(i)
if len(kkkk) != 0:
	print(jo(kkkk))

Solution (Python):


def submit():
    n = int(input())
    alist = [-1] + list(map(int, input().split()))

    i = n // 2
    while i > 0:
        j = i + i
        while j <= n:
            alist[i] += alist[j]
            j += i

        alist[i] %= 2
        i -= 1

    ans = alist[1:]

    print(sum(ans))
    for i, a in enumerate(ans):
        if a == 1:
            print(i + 1)

    return


if __name__ == '__main__':
    submit()

Solution (Python):
import sys
import copy


def input():
    return sys.stdin.readline()[:-1]


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = copy.copy(a)
    middle = len(a)//2-1
    ans = []

    for i in range(middle, -1, -1):
        s = 0
        b[i] = 0
        for j in range(i, n, i+1):
            s += b[j]
        b[i] = (s+a[i]) % 2

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

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


if __name__ == "__main__":
    main()

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

for i in range(N, 0, -1):
    if i > N // 2:
        b[i-1] = a[i-1]
    else:
        si = 0
        for j in range(i+i, N+1, i):
            si += b[j-1]
        if si % 2 == a[i-1]:
            b[i-1] = 0
        else:
            b[i-1] = 1

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

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

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

b_list = [0]*(N//2)+a_list[N//2:]
for i, a in enumerate(range(N//2)):
    j = N//2 - i

    j_list = []
    k = j
    while(1):
        j = j + k
        if j > N:
            break
        else:
            j_list.append(j)
    
    s = 0
    for j in j_list:
        s += b_list[j-1]

    if s % 2 == a_list[k-1]:
        b_list[k-1] = 0
    else:
        b_list[k-1] = 1

print(len([str(i+1) for i, b in enumerate(b_list) if b == 1]))
print(' '.join([str(i+1) for i, b in enumerate(b_list) if b == 1]))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = list(range(n))
k = 2
s = 0
for i in range(n):
  if (n/2-1) < (n-i-1):
    b[n-i-1] = a[n-i-1]
  else:
    while n > k*(n-i)-1:
      s += b[k*(n-i)-1]
      k += 1
    if s % 2 == a[n-i-1]:
      b[n-i-1] = 0
    else:
      b[n-i-1] = 1
  k = 2
  s = 0
ans = b.count(1)
print(ans)
for i in range(n):
  if b[i] == 1:
    print(i+1, end=" ")

Solution (Python):
N = int(input())
A_list = list(map(int, input().split()))
B_list = [0 for i in range(N)]
ans_list = ""

count = 0
for i in range(N-1, -1, -1):
    box_num = N // (i+1)
    sum_ball = 0
    for j in range(box_num):
        sum_ball += B_list[(j + 1) * (i + 1) - 1]
    if sum_ball % 2 != A_list[i]:
        B_list[i] = 1
        ans_list += str(i + 1) + " "
        count += 1




if count != 0:
    print(count)
    print(ans_list[:-1])
else:
    print(0)

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

for i in range(N-1,-1,-1):
    x = 2
    j = (i+1)*x-1
    while j <= N-1:
        A[i] = (A[i]-A[j])%2
        x += 1
        j = (i+1)*x-1
        

    if A[i] == 1:
        B.append(i+1)
        cnt +=1
B = [str(b) for b in B]

print(cnt)
if len(B) >= 1:
    print(' '.join(B))