class PascalsTriangle: def __init__(self, N): self.N = N self._build() def __call__(self, n, r): if n > self.N: raise "INVALID INPUT: input n must be smaller than N" if r < 0 or r > N: return 0 return self.nCr[n][r] def _build(self): tmp = [(1,)] for i in range(1, self.N + 1): nCi = tuple(1 if j in (0, i) else tmp[-1][j-1] + tmp[-1][j] for j in range(i+1)) tmp.append(nCi) self.nCr = tuple(tmp) if __name__ == "__main__": N = int(input()) A = list(map(int, input().split())) pt = PascalsTriangle(N) mod = 10 ** 9 + 7 ans = 0 for a, x in zip(A, pt.nCr[N - 1]): ans += a * x ans %= mod print(ans)