#include using namespace std; long long MOD = 1000000007; int main(){ long long N; cin >> N; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } long long ans = 0; for (long long i = 0; i < N; i++){ long long M = (i + 1) * (N - i) % MOD; ans = (ans + A[i] * M % MOD) % MOD; } cout << ans << endl; }