N = int(input()) A = list(map(int, input().split())) MOD = 10**9 + 7 def pascal_triangle(n): triangle = [] for depth in range(n): row = [] for i in range(depth + 1): if i == 0 or i == depth: row.append(1) else: v = (triangle[depth-1][i-1] + triangle[depth-1][i]) % MOD row.append(v) triangle.append(row) return triangle[-1] P = pascal_triangle(N) ans = 0 for i in range(N): ans += (A[i] * P[i]) % MOD ans %= MOD print(ans)