N = int(input()) A = list(map(int, input().split())) result = A[0] + A[N - 1] for i in range(1, N - 1): result += A[i] * (N - 1) result %= 1000000007 print(result)