N=int(input()) A=list(map(int,input().split())) DP=[0]*(N+20) FR=[-1]*(N+20) for i in range(N): for j in range(i-3,i-1): if DP[i]=0: IND=FR[IND] if IND>=0: L.append(IND+1) print(ANS) print(*L[::-1])