#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1e9 + 7;
ll modPow(ll a, ll b){
if(b == 0)return 1;
ll g = modPow(a, b / 2);
g *= g;
g %= MOD;
if(b & 1)g *= a;
g %= MOD;
return g;
}
void solve(){
int n;
cin >> n;
vector<ll> a(n);
for(int i = 0;i < n; i++){
cin >> a[i];
}
ll sum = 0;
multiset<pair<int, ll>> s;
for(int i = 0; i < n; i++){
int cnt = 0;
while(s.size()){
auto [p, q] = *(s.begin());
if(p <= a[i] || cnt >= 30 || ((1ll << cnt) * a[i]) >= p){
s.erase(s.find({p, q}));
ll g = modPow(2, q);
g *= p;
g %= MOD;
sum -= g;
if(sum < 0)sum += MOD;
sum += p;
sum %= MOD;
cnt += q;
}else break;
}
while(a[i] % 2 == 0){
cnt++;
a[i] /= 2;
}
if(cnt > 0){
s.insert({a[i], cnt});
}
// cout << cnt << " ";
ll g = modPow(2, cnt);
g *= a[i];
g %= MOD;
sum += g;
sum %= MOD;
cout << sum << " ";
}
cout << "\n";
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
for(int i = 1; i <= t; i++){
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1PRCA9IDFlOSArIDc7CgpsbCBtb2RQb3cobGwgYSwgbGwgYil7CglpZihiID09IDApcmV0dXJuIDE7CglsbCBnID0gbW9kUG93KGEsIGIgLyAyKTsKCWcgKj0gZzsKCWcgJT0gTU9EOwoJaWYoYiAmIDEpZyAqPSBhOwoJZyAlPSBNT0Q7CglyZXR1cm4gZzsKfQoKdm9pZCBzb2x2ZSgpewoJaW50IG47CgljaW4gPj4gbjsKCXZlY3RvcjxsbD4gYShuKTsKCQoJZm9yKGludCBpID0gMDtpIDwgbjsgaSsrKXsKCQljaW4gPj4gYVtpXTsKCX0KCQo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