class Combination: """ SIZEが10**6程度以下の二項係数を何回も呼び出したいときに使う 使い方: comb = Combination(SIZE, MOD) comb(10, 3) => 120 """ def __init__(self, N, MOD=10 ** 9 + 7): self.MOD = MOD self.__make_factorial_list(N) def __call__(self, n, k): if k < 0 or k > n: return 0 res = self.fact[n] * self.inv[k] % self.MOD res = res * self.inv[n - k] % self.MOD return res def nPk(self, n, k): if k < 0 or k > n: return 0 return self.fact[n] * self.inv[n - k] % self.MOD def __make_factorial_list(self, N): self.fact = [1] * (N + 1) self.inv = [1] * (N + 1) MOD = self.MOD for i in range(1, N + 1): self.fact[i] = (self.fact[i - 1] * i) % MOD self.inv[N] = pow(self.fact[N], MOD - 2, MOD) for i in range(N, 0, -1): self.inv[i - 1] = (self.inv[i] * i) % MOD return mod = 10 ** 9 + 7 N = int(input()) comb = Combination(N + 10, mod) ans = 0 for i, a in enumerate(map(int, input().split())): ans += a * comb(N - 1, i) ans %= mod print(ans)