#include<bits/stdc++.h>
using namespace std;
long m = 1e9+7;
int main()
{
long n; cin >> n;
long t[n];
for(int i = 0; i < n; i++)
{
long te; cin >> te; t[i] = te;
}
long k[n];
long summa = 0;
for(int i = 0; i < n; i++) k[i] = 2;
for(int i = 2; i < n; i++)
{
for(int i2 = 1; i2 <= n; i2++)
{
if(i2 < i)
{
//cout << "1: "<< i2-1 << " + " << i - abs(i - i2) << "\n";
k[i2-1] += i - abs(i - i2);
continue;
}
if(abs(i2 - n - 1) < i)
{
//cout << "2: " << i2-1 << " + " << i - abs(i - abs(i2-n - 1)) << "\n";
k[i2-1] += i - abs(i - abs(i2-n - 1));
continue;
}
else
{
//cout << "FULL: " << i2-1 << " + " << i << "\n";
k[i2-1] += i;
}
}
}
for(int i = 0; i < n; i++)
{
summa += k[i] * t[i] % m;
}
cout << summa % m << "\n";
}