#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define print(v) for(auto e:v) cout<<e<<" "; cout<<endl;
const int mod = 1e9 + 7;
long long Pow(ll a,ll b){
ll ans = 1;
while(b>0){
if(b&1) ans*=a;
b>>=1;
a*=a;
}
return ans;
}
ll gcd(ll a, ll b) {
while (b != 0) {
ll temp = b;
b = a % b;
a = temp;
}
return a;
}
void solve() {
int n; cin >> n;
ll ki = Pow(2 , n-1);
ll ans = 0;
vector<int>p(n);
for(int i = 0 ;i < n ; i++) {
cin >> p[i];
ans += ((p[i] % mod) * ( ki % mod) ) % mod;
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1; cin >> t;
while(t--){
solve();
}
return 0;
}