MOD = 10**9 + 7 N = int(input()) arr = list(map(int, input().split())) for i in range(1,N): for k in range(N-i): arr[k] += arr[k+1] print(arr[0]%MOD)