import numpy as np MOD = 10 ** 9 + 7 N = int(input()) A = np.array(list(map(int, input().split())), dtype=np.int64) for _ in range(N - 1): A = A[:-1] + A[1:] A %= MOD print(A[0])