mod = 10 ** 9 + 7 N, *A = map(int, open(0).read().split()) for _ in range(N - 1): A = [(a + b) % mod for a, b in zip(A, A[1:])] print(A[0])