// yukicoder: No.797 Noelちゃんとピラミッド // 2019.5.6 bal4u #include //// 高速入力 #if 1 #define gc() getchar_unlocked() #else #define gc() getchar() #endif int in() // 非負整数の入力 { int n = 0, c = gc(); // while (isspace(c)) c = gc(); do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0'); return n; } #define M 1000000007 #define MAX 100000 long long fact[MAX+2], inv[MAX+2], factinv[MAX+2]; long long comb(int n, int k) { if (n < 0 || k < 0 || n < k) return 0; if (k == 0) return 1LL; return (((fact[n] * factinv[k]) % M) * factinv[n-k]) % M; } int main() { int i, N; long long s = 0; for (fact[0] = 1, i = 1; i <= MAX; i++) fact[i] = (fact[i-1]*i) % M; for (inv[1] = 1, i = 2; i <= MAX; i++) inv[i] = (M + (-(M/i)*inv[M % i]) % M) % M; for (factinv[0] = 1, i = 1; i <= MAX; i++) factinv[i] = (factinv[i-1]*inv[i]) % M; N = in(); if (N <= 2) { while (N--) s += in(); } else { N--; for (i = 0; i <= N; i++) s += (comb(N, i)*in()) % M; } printf("%d\n", (int)(s % M)); return 0; }