n=int(input()) A=list(map(int,input().split())) while len(A)>1: l=[] for i in range(len(A)-1): a=A[i]+A[i+1] l.append(a) A=l print(sum(A)%(10**9+7))