N = int(input()) A = tuple(map(int, input().split())) T = [N] * N for i in range(N // 2): T[i + 1] = T[i] + N - (i + 1) * 2 T[N - i - 2] = T[i + 1] print(sum(A[i] * T[i] for i in range(N)) % (10 ** 9 + 7))