#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 100000, M = 1000000007;
int t, n, ans[N];
pair<int, int> a[N];
int solve(int x, int i) {
int ret;
if (i != n - 1) ret = (x + a[n - 1].first) % M;
else ret = (x + a[n - 2].first) % M;
int idx = upper_bound(a, a + n, make_pair(M - 1 - x, 1000000000)) - a;
if (idx > 0 && idx < n) {
if (i != idx - 1) ret = max(ret, (x + a[idx - 1].first) % M);
else if (idx - 2 >= 0) ret = max(ret, (x + a[idx - 2].first) % M);
}
return ret;
}
int main() {
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i].first);
a[i].second = i;
}
sort(a, a + n);
for (int i = 0; i < n; ++i)
ans[a[i].second] = solve(a[i].first, i);
printf("%d", ans[0]);
for (int i = 1; i < n; ++i)
printf(" %d", ans[i]);
puts("");
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnR5cGVkZWYgbG9uZyBsb25nIGxsOwp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgTiA9IDEwMDAwMCwgTSA9IDEwMDAwMDAwMDc7CmludCB0LCBuLCBhbnNbTl07CnBhaXI8aW50LCBpbnQ+IGFbTl07CgppbnQgc29sdmUoaW50IHgsIGludCBpKSB7CglpbnQgcmV0OwoJaWYgKGkgIT0gbiAtIDEpIHJldCA9ICh4ICsgYVtuIC0gMV0uZmlyc3QpICUgTTsKCWVsc2UJCSAgICByZXQgPSAoeCArIGFbbiAtIDJdLmZpcnN0KSAlIE07CglpbnQgaWR4ID0gdXBwZXJfYm91bmQoYSwgYSArIG4sIG1ha2VfcGFpcihNIC0gMSAtIHgsIDEwMDAwMDAwMDApKSAtIGE7CglpZiAoaWR4ID4gMCAmJiBpZHggPCBuKSB7CgkJaWYgKGkgIT0gaWR4IC0gMSkgICAgICByZXQgPSBtYXgocmV0LCAoeCArIGFbaWR4IC0gMV0uZmlyc3QpICUgTSk7CgkJZWxzZ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