n = int(input()) A = list(map(int,input().split())) mod = 10**9+7 for i in range(n-1): nA = [] for a,na in zip(A,A[1:]): nA.append((a+na)%mod) A = nA print(A[0])