N=int(input()) A=list(map(int,input().split())) for i in range(N,2,-1): A[i-2]+=A[i] if A[2]: print(*A[:3]) elif A[1]: print(*A[:2]) else: print(A[0])