CodeEff/ECCO huggingface dataset:
# Original solution
import sys

input = sys.stdin.buffer.readline


class SegmentTree:
    ele = 0
    func = max
    # SEG木は1-index
    # Aに関しては0-index

    def __init__(self, n):  # Aは0-idx
        self.n = n
        self.num = 2 ** ((self.n - 1).bit_length())
        self.SEG = [self.ele] * (2 * self.num)

    def search(self, idx):
        return self.SEG[idx + self.num]

    def initialize(self, A):
        for i in range(self.n):
            self.SEG[i + self.num] = A[i]
        for i in range(self.num - 1, 0, -1):
            self.SEG[i] = self.func(self.SEG[2 * i], self.SEG[2 * i + 1])

    # 1点更新
    def set(self, idx, val):
        idx += self.num
        self.SEG[idx] = val
        idx //= 2
        while idx:
            self.SEG[idx] = self.func(self.SEG[2 * idx], self.SEG[2 * idx + 1])
            idx //= 2

    # 区間取得
    def query(self, left, right):
        # 開区間
        resleft = self.ele
        resright = self.ele
        left += self.num
        right += self.num
        while right - left > 0:
            if left % 2 == 1:
                resleft = self.func(resleft, self.SEG[left])
                left += 1
            if right % 2 == 1:
                right -= 1
                resright = self.func(resright, self.SEG[right])
            left //= 2
            right //= 2
        return self.func(resleft, resright)


n, k = list(map(int, input().split()))
ans = 0
ST = SegmentTree(3000001)
for _ in range(n):
    val = int(eval(input()))
    lower = val - k
    lower = max(lower, 0)
    upper = val + k
    upper = min(upper, 3000000)
    temp = ST.query(lower, upper + 1) + 1
    ST.set(val, temp)
    ans = max(ans, temp)
print(ans)


# Optimized solution
import sys


input = sys.stdin.buffer.readline

n, k = list(map(int, input().split()))
max_n = 300000
num = 2 ** ((max_n - 1).bit_length())
SEG = [0] * (2 * num)
func = max
ele = 0


def update(idx, val):
    idx += num
    SEG[idx] = val
    while idx > 0:
        idx //= 2
        SEG[idx] = func(SEG[2 * idx], SEG[2 * idx + 1])


def query(left, right):
    res_left = ele
    res_right = ele
    left += num
    right += num
    while right - left > 0:
        if left & 1:
            res_left = func(res_left, SEG[left])
            left += 1
        if right & 1:
            right -= 1
            res_right = func(SEG[right], res_right)
        left //= 2
        right //= 2
    return func(res_left, res_right)


for _ in range(n):
    val = int(eval(input()))
    temp = query(max(0, val - k), min(max_n + 1, val + k + 1))
    temp += 1
    update(val, temp)


print((SEG[1]))
# Original solution
from collections import Counter
while True:
    W, D = list(map(int, input().split()))
    if not (W | D):
        break
    hw = [int(x) for x in input().split()]
    hd = [int(x) for x in input().split()]
    print((sum(hw) + sum(hd) - sum(k * v for k, v in list((Counter(hw) & Counter(hd)).items()))))

# Optimized solution
from collections import Counter
import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input
while True:
    W, D = list(map(int, input().split()))
    if not (W | D):
        break
    hw = [int(x) for x in input().split()]
    hd = [int(x) for x in input().split()]
    print((sum(hw) + sum(hd) - sum(k * v for k, v in list((Counter(hw) & Counter(hd)).items()))))
# Original solution
n = int(eval(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)

# Optimized solution
n = int(eval(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)
# Original solution
def divisors(n):
    ds = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ds.append(i)
            if i != n // i:# and i != 1:
                ds.append(n//i)
    # divisors.sort()
    return ds

n = int(eval(input()))
aa = list(map(int, input().split()))
counts = {}
balls = {}


for i in range(len(aa)):
    if aa[i] == 1:
        counts[i + 1] = 1
    else:
        counts[i + 1] = 0

for i in range(n, 0, -1):
    #print(f'i = {i}, counts={counts}')
    if counts[i] % 2 == 0:
        continue
    # put ball in i
    balls[i] = True
    ds = divisors(i)
    for d in ds:
        counts[d] += 1
balls = list(balls.keys())
print((len(balls)))
if len(balls) > 0:
    print((' '.join(map(str, balls))))



# Optimized solution
n = int(eval(input()))
aa = list(map(int, input().split()))
balls = {}
ai = {}
for i in range(len(aa)):
    if aa[i] == 1:
        ai[i + 1] = 1
    else:
        ai[i + 1] = 0


for i in range(n, 0, -1):
    parity = 0
    k = 1
    while k * i <= n:
        if k * i in balls:
            parity ^= 1
        k += 1
    if parity != ai[i]:
        balls[i] = True

print((len(balls)))
if len(balls) > 0:
    print((' '.join(map(str, balls))))
# Original solution
n = int(eval(input()))
a = [int(i) for i in input().split()]
b = [0] * n
ans = []
for i in range(n, 0, -1):
    multi_list = [j for j in range(1, n + 1, 1) if j % i == 0]
    for multi in multi_list:
        b[i - 1] = (b[i - 1] + a[multi - 1]) % 2
    if b[i - 1] == 1:
        ans.append(str(i))
if a == b:
    print((len(ans)))
    if len(ans) > 0:
        print((" ".join(ans)))
else:
    print("-1")

# Optimized solution
n = int(eval(input()))
a = [int(i) for i in input().split()]
b = [0] * n
ans = []
for i in range(n, 0, -1):
    temp = sum(b[i - 1:n:i]) % 2
    if temp != a[i - 1]:
        b[i - 1] = 1
    if b[i - 1] == 1:
        ans.append(str(i))
print((len(ans)))
if len(ans) > 0:
    print((" ".join(ans)))
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from functools import reduce
from operator import xor

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

B = [0] * (N+1)
for n in range(N,0,-1):
    s = reduce(xor,B[n+n::n],0)
    B[n] = s^A[n]

I = [i for i,x in enumerate(B) if x]

print((len(I)))
if len(I) > 0:
    print((' '.join(map(str,I))))

# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from functools import reduce
from operator import xor

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

for n in range(N//2,0,-1):
    A[n] = reduce(xor,A[n::n],0)

I = [i for i,x in enumerate(A) if x]

print((len(I)))
if len(I) > 0:
    print((' '.join(map(str,I))))
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from functools import reduce
from operator import xor

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

for n in range(N//2,0,-1):
    A[n] = reduce(xor,A[n::n],0)

I = [i for i,x in enumerate(A) if x]

print((len(I)))
if len(I) > 0:
    print((' '.join(map(str,I))))

# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

for n in range(N//2,0,-1):
    A[n] = sum(A[n::n])&1

I = [i for i,x in enumerate(A) if x]

print((len(I)))
if len(I) > 0:
    print((' '.join(map(str,I))))
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))

last_ans = 0

for i in range(2 ** N):
    hako = [0]*N
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            hako[j] = 1

    #print(hako)
    ans = 0
    for kijun in range(1,N+1):
        baisuu = 1
        total = 0
        while kijun*baisuu <= N:
            if hako[kijun*baisuu-1] == 1:
                total += 1
            baisuu += 1

        total %= 2
        if a[kijun-1] != total:
            ans = 1
            break

    if ans == 0:
        last_ans = 1
        break

if last_ans == 1:
    print((hako.count(1)))
    if hako.count(1) != 0:
        buf = [i+1 for i, x in enumerate(hako) if x == 1]
        print((' '.join(map(str, buf))))
else:
    print((-1))

# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))

hako = [0]*N
last_ans = 1

for i in range(N-1, -1, -1):
    #print(i)
    check = 0
    kijun = i+1
    baisuu = 1
    total = 0
    while kijun*baisuu <= N:
        if hako[kijun*baisuu-1] == 1:
            total += 1
        baisuu += 1
    total %= 2
    if total != a[i]:
        hako[i] = 1

if last_ans == 1:
    print((hako.count(1)))
    if hako.count(1) != 0:
        buf = [i+1 for i, x in enumerate(hako) if x == 1]
        print((' '.join(map(str, buf))))
else:
    print((-1))
# Original solution
n=int(eval(input()))
li=list(map(int,input().split()))

ans=[]
for i in range(n-1,n//2-1,-1):
  if li[i]==1:
    ans.append(i+1)

for i in range(n//2,0,-1):
  count=0
  for j in ans:
    if j%i==0:
      count+=1
  if count%2!=li[i-1]:
    ans.append(i)
ans.reverse()
print((len(ans)))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

# Optimized solution
n=int(eval(input()))
li=list(map(int,input().split()))

ans=[]
li2=[0 for _ in range(n)]
for i in range(n,0,-1):
  count=0
  for j in range(i*2,n+1,i):
    if li2[j-1]==1:
      count+=1
  if count%2!=li[i-1]:
    li2[i-1]=1
    ans.append(i)

ans.reverse()
print((len(ans)))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)
# Original solution
import sys

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)

    # divisors.sort()
    return divisors

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

a.insert(0, -1)

env = [0] * (n+1)
hako = [0] * (n+1)
ind = []

for _ in range(n):
    i = n - _
    if a[i] != env[i]:
        hako[i] = 1
        ind.append(str(i))
        yakusuu = make_divisors(i)
        for j in yakusuu:
            if env[j] == 0:
                env[j] = 1
            else:
                env[j] = 0

goukei = sum(hako)
print(goukei)
if ind == []:
    sys.exit()
mojiretu = ' '.join(ind)
print(mojiretu)

# Optimized solution
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)

    # divisors.sort()
    return divisors

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

a.insert(0, -1)

env = [0] * (n+1)
hako = [0] * (n+1)
ind = []

for _ in range(n):
    i = n - _
    if a[i] != env[i]:
        hako[i] = 1
        ind.append(str(i))
        yakusuu = make_divisors(i)
        for j in yakusuu:
            if env[j] == 0:
                env[j] = 1
            else:
                env[j] = 0

goukei = sum(hako)
print(goukei)
if ind != []:
    mojiretu = ' '.join(ind)
    print(mojiretu)
# Original solution
import sys
sys.setrecursionlimit(4100000)

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    N = [int(x) for x in sys.stdin.readline().split()][0]
    a_list = [int(x) for x in sys.stdin.readline().split()]

    logger.debug('{} {}'.format(N, a_list))

    box_list = [0 for _ in range(N)]

    for i in reversed(list(range(N))):
        suma = sum(
            [box_list[j] for j in range(i + 1, N) if (j + 1) % (i + 1) == 0])

        r = suma % 2
        if r != a_list[i]:
            box_list[i] = 1

    s = sum(box_list)
    print(s)

    if s > 0:
        print((' '.join(
            [str(i + 1) for i in range(len(box_list)) if box_list[i]])))


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1 0 0"""
        output = """1
1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5
0 0 0 0 0"""
        output = """0"""
        self.assertIO(input, output)

# Optimized solution
import sys
sys.setrecursionlimit(4100000)

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


# @profile
def resolve():
    N = [int(x) for x in sys.stdin.readline().split()][0]
    a_list = [int(x) for x in sys.stdin.readline().split()]

    logger.debug('{} {}'.format(N, a_list))

    box_list = [0 for _ in range(N)]

    for i in reversed(list(range(N))):
        suma = sum(box_list[i:N:i+1])

        r = suma % 2
        if r != a_list[i]:
            box_list[i] = 1

    s = sum(box_list)
    print(s)

    if s > 0:
        print((' '.join(
            [str(i + 1) for i in range(len(box_list)) if box_list[i]])))


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1 0 0"""
        output = """1
1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5
0 0 0 0 0"""
        output = """0"""
        self.assertIO(input, output)
# Original solution
def main():
    n = int(eval(input()))
    s = list(map(int,input().split()))
    r = []
    for i in range(n,0,-1):
        c = sum(x % i == 0 for x in r)
        c1 = c % 2
        if c1 != s[i-1]:
            r.append(int(i))

    print((len(r)))
    if len(r) > 0:
        for i in range(len(r)):
            r[i] = str(r[i])
        print((" ".join(r)))
    
if __name__ == "__main__":
    main()

# Optimized solution
def main():
    n = int(eval(input()))
    s = list(map(int,input().split()))
    r = [0] * n
    for i in range(n,n//2,-1):
        if s[i-1] == 1:
            r[i-1] = 1
    for i in range(n//2,0,-1):
        p = n // i
        c = 0
        for j in range(1,p+1):
            if r[(j * i) - 1] == 1:
                c += 1
        if c % 2 != s[i-1]:
            r[i-1] = 1

    o = sum(r)
    print(o)
    if o > 0:
        u = []
        for i in range(len(r)):
            if r[i] == 1:
                u.append(str(i+1))
        print((" ".join(u)))
    
if __name__ == "__main__":
    main()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
B = [0 for n in range(N+1)]
x = []

for n in range(N):
  i = N-n
  # print(i)
  BB = B[::i]
  if (sum(BB))%2 == A[i-1]:
    B[i] = 0
  else:
    B[i] = 1
    # print(B)
  if B[i] == 1:
    x.append(str(i))
  
if len(x) == 0:
  print((0))
else:
  print((len(x)))
  print((' '.join(x)))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
B = [0]*(N+1)
x = []

for n in range(N):
  i = N-n
  BB = B[::i]
  if (sum(BB))%2 == A[i-1]:
    B[i] = 0
  else:
    B[i] = 1
    x.append(str(i))
  
if len(x) == 0:
  print((0))
else:
  print((len(x)))
  print((' '.join(x)))
# Original solution
N = int(eval(input()))
An = input().split(' ')
ball_list = [0] * N
output_list = []
count = 0
for i in range(N):
    sum_amari = sum(ball_list[(N - i -1)::(N - i)])
    if sum_amari % 2 != int(An[N - i -1]): 
        ball_list[N - i -1] = 1
        output_list.insert(0,str(N - i))

print((len(output_list)))
if len(output_list) > 0:
    print((' '.join(output_list)))

# Optimized solution
N = int(eval(input()))
An = input().split(' ')
ball_list = [0] * N
output_list = []
count = 0
for i in range(N):
    sum_amari = sum(ball_list[(N - i -1)::(N - i)])
    if sum_amari % 2 != int(An[N - i -1]): 
        ball_list[N - i -1] = 1
        output_list.append(str(N - i))
output_list.reverse()
print((len(output_list)))
if len(output_list) > 0:
    print((' '.join(output_list)))
# Original solution
N = int(eval(input()))
a_list = [int(x) for x in input().split()]
cnt = 0
b_list = []
for i in range(len(a_list), 0, -1):
    if ( a_list[i-1] != len(list([b for b in b_list if b%i == 0])) %2):
        b_list.append(i)
M = len(b_list)
print(M)
if (M>0):
    print((" ".join([str(b) for b in b_list])))


# Optimized solution
N = int(eval(input()))
a_list = [int(x) for x in input().split()]
cnt = 0
b_list = set()
for i in range(len(a_list), 0, -1):
    tmp = 0
    for j in range(i*2, N+1, i):
        tmp ^= (j in b_list)
    if (tmp != a_list[i-1]):
        b_list.add(i)
M = len(b_list)
print(M)
if (M>0):
    print((" ".join([str(b) for b in b_list])))
# Original solution
n = int(eval(input()))
a = [-1] + list(map(int, input().split()))

b = [0] * (n+1)
for i in reversed(list(range(1, n+1))):
    bi = 0
    for j in range(2, n//i + 1):
        bi += b[i*j]
    bi %= 2

    if bi != a[i]:
        b[i] = 1
    else:
        b[i] = 0

b_idx = [str(i) for i in range(1, n+1) if b[i] == 1]
m = len(b_idx)
print(m)
if m > 0:
    print((' '.join(b_idx)))


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))

b = [0] * (n+1)
for i in reversed(list(range(1, n+1))):
    bi = 0
    for j in range(2, n//i + 1):
        bi += b[i*j]
    bi %= 2

    if bi != a[i-1]:
        b[i] = 1
    else:
        b[i] = 0

b_idx = [str(i) for i in range(1, n+1) if b[i] == 1]
m = len(b_idx)
print(m)
if m > 0:
    print((' '.join(b_idx)))
# Original solution
def main():
    n = int(eval(input()))
    a = list(map(int,input().split()))
    ans = [0 for i in range(n+1)]
    for i in range(n):
        s = 0
        k = n-i
        for j in range(1,n//k+1):
            s += ans[k*j]
        if s%2!=a[k-1]:
            ans[k] = 1
    print((sum(ans)))
    if sum(ans)!=0:
        print((' '.join([str(i) for i , x in enumerate(ans) if x==1])))



if __name__ == "__main__":
    main()

# Optimized solution
def main():
    n = int(eval(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)))))

if __name__ == "__main__":
    main()
# Original solution
n = int(eval(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(i+1)
        else:
            pass
    BB = [str(a) for a in B]
    BB =" ".join(BB)
    print(BB)


# Optimized solution
n = int(eval(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)
# Original solution
from functools import lru_cache, reduce
from operator import xor


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


# 右の箱から順に詰める
@lru_cache(maxsize=None)
def f(i):
    return reduce(
        xor,
        (f(j) for j in range(2 * i, N + 1, i)),
        a[i - 1]
    )


b = [i for i in reversed(list(range(1, N + 1))) if f(i)]
ans = (
    '0' if len(b) == 0 else
    '{}\n{}'.format(
        len(b),
        ' '.join(map(str, b))
    )
)

print(ans)


# Optimized solution
from functools import reduce
from operator import xor


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


# 右の箱から順に詰める
dp = [0 for _ in range(N + 1)]
for i in range(N, 0, -1):
    dp[i] = reduce(
        xor,
        (dp[j] for j in range(2 * i, N + 1, i)),
        a[i - 1]
    )
b = [i for i in range(1, N + 1) if dp[i]]
ans = (
    '0' if len(b) == 0 else
    '{}\n{}'.format(
        len(b),
        ' '.join(map(str, b))
    )
)

print(ans)
# Original solution
n = int(eval(input()))
ai = list(map(int, input().split()))

#print(ai)
dai={}
dbi={}
for i in range(1, n+1):
    dai.setdefault(i, ai[i-1])
    dbi.setdefault(i, 0)

#print(dai)
#print(dbi)

anssum=0
ans=[]
for i in range(1, n+1)[::-1]:
    #print(i)
    tmp=0
    for j in range(2, n+1):
        check=i*j
        if check <= n:
            tmp = tmp + dbi[check]
    tmp = tmp%2
    #print(str(tmp) + ", " + str(dai[i]))
    if tmp != dai[i]:
        dbi[i]=1
        anssum=anssum+1
        ans.append(i)

#print(dbi)
print(anssum)
if anssum != 0:
    print((" ".join(map(str, reversed(ans)))))

# Optimized solution
n = int(eval(input()))
ai = list(map(int, input().split()))

#print(ai)
dai={}
dbi={}
for i in range(1, n+1):
    dai.setdefault(i, ai[i-1])
    dbi.setdefault(i, 0)

#print(dai)
#print(dbi)

anssum=0
ans=[]
for i in range(1, n+1)[::-1]:
    #print(i)
    tmp=0
    for j in range(2, n+1):
        check=i*j
        if check <= n:
            tmp = tmp + dbi[check]
        else:
            break
    tmp = tmp%2
    #print(str(tmp) + ", " + str(dai[i]))
    if tmp != dai[i]:
        dbi[i]=1
        anssum=anssum+1
        ans.append(i)

#print(dbi)
print(anssum)
if anssum != 0:
    print((" ".join(map(str, reversed(ans)))))
# Original solution
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
c=[]
cnt=0
for i in range(1,N+1)[::-1]:
  if len([x for x in c if x%i==0])%2 != a[i-1]:
    a[i-1]=1
    c.append(i)
    cnt+=1
print(cnt)
if len(c)>0:
  print(*c,sep='\n')


# Optimized solution
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')
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))

ans = [0 for x in range(N+1)]
for i in range(N,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        if ans[j] == 1:
            s += 1
    ans[i] = s & 1 != A[i-1]

ans_m = 0
ans_a = []
for i in range(len(ans)):
    if ans[i]:
        ans_m += 1
        ans_a.append(i)

print(ans_m)
if ans_m > 0:
    print((" ".join(map(str,ans_a))))



# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))

ans = [0 for x in range(N+1)]
ans_m = 0
ans_a = []
for i in range(N,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        if ans[j] == 1:
            s += 1
    if s & 1 != A[i-1]:
        ans[i] = 1
        ans_m += 1
        ans_a.append(i)

print(ans_m)
if ans_m > 0:
    print((" ".join(map(str,ans_a))))