class Ncrs(): def __init__(self, max_r, mod = 10**9+7) -> None: self.mod = mod self.fct, self.inv = [1] * (max_r+2), [1]* (max_r+2) for i in range(2, max_r+1): self.fct[i] = self.fct[i-1] * i % mod self.inv[max_r] = pow(self.fct[max_r], mod-2, mod) for i in range(max_r, 0,-1): self.inv[i-1] = self.inv[i] * i % mod def __call__(self, n, k) -> int: return self.nck(n, k) def nck(self, n, k) -> int: if k > n or n <0 or k <0: return 0 return self.fct[n] * self.inv[k] % self.mod * self.inv[n-k] % self.mod N = int(input()) ncr = Ncrs(N-1) a = list(map(int, input().split())) res = 0 for i in range(N): res += ncr(N-1, i)*a[i] res %= 10**9+7 print(res)