Buggy python submission (verdict: Runtime Error):
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    ANS=[]
    PAL=[0 for i in range(M)]
    for i in reversed(range(M)):
        if 2*(i+1)>M:
            PAL[i]+=B[i]
            if B[i]==1:
                ANS.append(i+1)
        else:
            if PAL[i]!=B[i]:
                PAL[i]=(PAL[i]+1)%2
                ANS.append(i+1)
        for j in fact[i]:
                PAL[j]=(PAL[j]+PAL[i])%2
            
            
    print(len(ANS))
    print(' '.join(map(str,ANS)))

        



Fixed submission:
#ABC134-D
if True:
    N=int(input())
    A=[int(i) for i in input().split()]
    fact=[[1] for i in range(N)]
    for i in range(2,N+1):
        k=2
        while k*i<=N:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    SUM=[0 for i in range(N)]
    ANS=[]
    for i in reversed(range(N)):
        if (i+1)*2>N:
            if A[i]==1:
                ANS.append(i+1)
                SUM[i]=A[i]
            for j in fact[i]:
                SUM[j-1]=(SUM[j-1]+A[i])%2
        else:
            if SUM[i]==1:
                if A[i]==1:
                    continue
                else:
                    ANS.append(i+1)
                    SUM[i]=1
                    for j in fact[i]:
                        SUM[j-1]=(SUM[j-1]+1)%2
            else:
                if A[i]==0:
                    continue
                else:
                    ANS.append(i+1)
                    SUM[i]=1
                    for j in fact[i]:
                        SUM[j-1]=(SUM[j-1]+1)%2
    print(len(ANS))
    print(' '.join(map(str,ANS)))

Buggy python submission (verdict: Runtime Error):
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    ANS=[]
    PAL=[0 for i in range(M)]
    for i in reversed(range(M)):
        if 2*(i+1)>M:
            PAL[i]+=B[i]
            if B[i]==1:
                ANS.append(i+1)
        else:
            if PAL[i]!=B[i]:
                PAL[i]+=1
                ANS.append(i+1)
        for j in fact[i]:
                PAL[j]=(PAL[j]+PAL[i])%2
            
            
    print(len(ANS))
    print(' '.join(map(str,ANS)))

        



Fixed submission:
#ABC134-D
if True:
    N=int(input())
    A=[int(i) for i in input().split()]
    fact=[[1] for i in range(N)]
    for i in range(2,N+1):
        k=2
        while k*i<=N:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    SUM=[0 for i in range(N)]
    ANS=[]
    for i in reversed(range(N)):
        if (i+1)*2>N:
            if A[i]==1:
                ANS.append(i+1)
                SUM[i]=A[i]
            for j in fact[i]:
                SUM[j-1]=(SUM[j-1]+A[i])%2
        else:
            if SUM[i]==1:
                if A[i]==1:
                    continue
                else:
                    ANS.append(i+1)
                    SUM[i]=1
                    for j in fact[i]:
                        SUM[j-1]=(SUM[j-1]+1)%2
            else:
                if A[i]==0:
                    continue
                else:
                    ANS.append(i+1)
                    SUM[i]=1
                    for j in fact[i]:
                        SUM[j-1]=(SUM[j-1]+1)%2
    print(len(ANS))
    print(' '.join(map(str,ANS)))

Buggy python submission (verdict: Runtime Error):
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    ANS=[2 for i in range(M)]
    for i in reversed(range(M)):
        if (i+1)*2>M:
            ANS[i]=B[i]
            for j in fact[i]:
                ANS[j-1]+=ANS[i]
        else:
            if B[j]!=(ANS[j]%2):
                ANS[j]+=1
        # print(ANS)
    print(N)
    for ans in ANS:
        print(ans)

        



Fixed submission:
#ABC134-D
if True:
    N=int(input())
    A=[int(i) for i in input().split()]
    fact=[[1] for i in range(N)]
    for i in range(2,N+1):
        k=2
        while k*i<=N:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    SUM=[0 for i in range(N)]
    ANS=[]
    for i in reversed(range(N)):
        if (i+1)*2>N:
            if A[i]==1:
                ANS.append(i+1)
                SUM[i]=A[i]
            for j in fact[i]:
                SUM[j-1]=(SUM[j-1]+A[i])%2
        else:
            if SUM[i]==1:
                if A[i]==1:
                    continue
                else:
                    ANS.append(i+1)
                    SUM[i]=1
                    for j in fact[i]:
                        SUM[j-1]=(SUM[j-1]+1)%2
            else:
                if A[i]==0:
                    continue
                else:
                    ANS.append(i+1)
                    SUM[i]=1
                    for j in fact[i]:
                        SUM[j-1]=(SUM[j-1]+1)%2
    print(len(ANS))
    print(' '.join(map(str,ANS)))