// Errichto
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
const int mod = 1e9 + 7;
int main() {
int n;
scanf("%d", &n);
long long s = 0;
RI(i, n) {
int a;
scanf("%d", &a);
if(n == 1) {
printf("%d\n", a);
return 0;
}
s = (s + (long long) a * (i + 1)) % mod;
}
REP(_, n - 2) s = 2 * s % mod;
printf("%d\n", (int) s);
return 0;
}
Ly8gRXJyaWNodG8KI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBGT1IoaSxhLGIpIGZvcihpbnQgaSA9IChhKTsgaSA8PSAoYik7ICsraSkKI2RlZmluZSBSSShpLG4pIEZPUihpLDEsKG4pKQojZGVmaW5lIFJFUChpLG4pIEZPUihpLDAsKG4pLTEpCgpjb25zdCBpbnQgbW9kID0gMWU5ICsgNzsKCmludCBtYWluKCkgewoJaW50IG47CglzY2FuZigiJWQiLCAmbik7Cglsb25nIGxvbmcgcyA9IDA7CglSSShpLCBuKSB7CgkJaW50IGE7CgkJc2NhbmYoIiVkIiwgJmEpOwoJCWlmKG4gPT0gMSkgewoJCQlwcmludGYoIiVkXG4iLCBhKTsKCQkJcmV0dXJuIDA7CgkJfQoJCXMgPSAocyArIChsb25nIGxvbmcpIGEgKiAoaSArIDEpKSAlIG1vZDsKCX0KCVJFUChfLCBuIC0gMikgcyA9IDIgKiBzICUgbW9kOwoJcHJpbnRmKCIlZFxuIiwgKGludCkgcyk7CglyZXR1cm4gMDsKfQo=