/*
Here's a more beautiful way to solve this problem, than my last one =)
Example for
n = 4, L = [1, 2, 3, 4]
Here are all formable sums. Summing those up give the result.
1
1 2
1 2 3
1 2 3 4
2
2 3
2 3 4
3
3 4
4
*/
#include <iostream>
using namespace std;
typedef long long ll;
ll n;
ll s[100001];
ll part[101010];
int main(int argc, char** argv) {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n; cin.ignore();
for (int i = 1; i <= n; i++) {
ll e; cin >> e;
s[i] = e;
}
ll r = 0LL;
for (ll i = n; i > 0; i--) {
ll multi = n - i + 1; // How many times to multiply this number.
ll accum = part[i + 1]; // Add what we've accumulated so far.
ll curr = multi * s[i]; // Multiply by the current number.
part[i] = curr + accum; // Set the new accumulator.
r += part[i]; // Add the accumulated sum to the result sum.
r %= 1000000007LL; // Modulo the result sum.
}
cout << r;
return 0;
}