N = gets.chop.to_i a = gets.chop.split.map(&:to_i) if N == 1 puts a[0] exit end MOD = 10**9 + 7 MAX = N + 100 def fact_mod() $fact = Array.new(MAX, 0) $fact[0] = 1 for i in 1..MAX - 1 $fact[i] = $fact[i - 1] * i % MOD end end def inv_mod() $inv = Array.new(MAX, 0) $inv[0] = 1 $inv[1] = 1 for i in 2..MAX - 1 $inv[i] = MOD - $inv[MOD % i] * (MOD / i) % MOD end end def fact_inv_mod() $factInv = Array.new(MAX, 0) $factInv[0] = 1 for i in 1..MAX - 1 $factInv[i] = $factInv[i - 1] * $inv[i] % MOD end end def make_mod() fact_mod() inv_mod() fact_inv_mod() end def comb_mod(n, k) if n < k return 0 end if n < 0 || k < 0 return 0 end return $fact[n] * (($factInv[k] * $factInv[n - k]) % MOD) % MOD end make_mod() ans = 0 for i in 1..N ans += a[i - 1] * (comb_mod(N - 1, i - 1) % MOD) end puts (ans % MOD).to_i