import sequtils,strutils,strscans,algorithm,math,future,macros template get*():string = stdin.readLine() #.strip() let D = get().parseInt() var A = get().split().map(parseInt) for i in countdown(D, 3): A[i-2] += A[i] if A.len >= 3 and A[2] != 0: echo 2 echo A[0..2].mapIt($it).join(" ") elif A.len >= 2 and A[1] != 0: echo 1 echo A[0..1].mapIt($it).join(" ") else: echo 0 echo A[0]