mod=10**9+7 n=int(input()) arr=list(map(int,input().split())) ans=0 for i in range(n): c=2**min(i,(n-1-i)) ans+=arr[i]*(c%mod) ans%=mod print(ans)