import math as m
ans = []
def flip(i):
b = (i + m.ceil(len(a)/2)-1 % len(a)) + 1
c = (i - m.ceil(len(a)/2) - 1 % len(a)) + 1
ans.append(i)
if(a[i]==0):
a[i] = 1
else:
a[i] = 0
if((b>0) and b<len(a)):
if(a[b] == 0):
a[b] = 1
else:
a[b] = 0
if((c>0) and c<len(a)):
if(a[c] == 0):
a[c] = 1
else:
a[c] = 0
n = input("")
a = input("").split(" ")
a = [int(i) for i in a]
l = int(n)-1
if(a[(l)] == 1):
flip((len(a)-1))
r = int((len(a)-1)/2)
for i in range(int(n)*7):
while(r>1):
if(a[r]==0):
flip(r)
break
else:
r = int(r/2)
if(len(ans) != 0):
print(len(ans))
print(ans)
else:
print(-1)
Copy