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