N = int(input()) A = list(map(int,input().split())) P = 10 ** 9 + 7 dp = [[0] * N for _ in range(N)] for i in range(N): dp[0][i] = A[i] for i in range(N-1): for j in range(N-1-i): dp[i+1][j] = (dp[i][j] + dp[i][j+1]) % P print(dp[N-1][0])