n = int(input()) a = [int(i) for i in input().split()] mod = 10**9+7 def c(n,k): if(k<=0 or n<=k): return 1 else: return(c(n-1, k-1) + c(n-1, k)) ans = 0 for i in range(n): ans += c(n-1,i)*a[i] ans %= mod print(ans)