import math def comb(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) MOD = int(1e9+7) n = int(input()) a = input().split() ans = 0 for i,j in enumerate(a): ans += int(j)*comb(n-1, int(i)) ans %= MOD print(ans)