N = int(input()) A = [int(a) for a in input().split()] for i in range(1, N)[::-1]: A = [A[i] + A[i+1] for i in range(i)] print(A[0] % (10 ** 9 + 7))