#include <bits/stdc++.h>
using namespace std;
const int N = 1e5, M = 1e9 + 7;
int n, sol[N];
pair<int, int> a[N];
int main(int argc, char **argv) {
int t;
scanf("%d", &t);
while (t-- != 0) {
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) {
int cur = a[i].second;
if (i + 1 == n)
sol[cur] = (a[i].first + a[n - 2].first) % M;
else
sol[cur] = (a[i].first + a[n - 1].first) % M;
int k = upper_bound(a, a + n, make_pair(M - a[i].first - 1, N)) - a - 1;
if (k >= 0) {
if (k != i)
sol[cur] = max(sol[cur], (a[i].first + a[k].first) % M);
else if (k - 1 >= 0)
sol[cur] = max(sol[cur], (a[i].first + a[k - 1].first) % M);
}
}
for (int i = 0; i < n; ++i)
printf("%s%d", i ? " " : "", sol[i]);
puts("");
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgTiA9IDFlNSwgTSA9IDFlOSArIDc7CmludCBuLCBzb2xbTl07CnBhaXI8aW50LCBpbnQ+IGFbTl07CgppbnQgbWFpbihpbnQgYXJnYywgY2hhciAqKmFyZ3YpIHsKCWludCB0OwoJc2NhbmYoIiVkIiwgJnQpOwoJd2hpbGUgKHQtLSAhPSAwKSB7CgkJc2NhbmYoIiVkIiwgJm4pOwoJCWZvciAoaW50IGkgPSAwOyBpIDwgbjsgKytpKSB7CgkJCXNjYW5mKCIlZCIsICZhW2ldLmZpcnN0KTsKCQkJYVtpXS5zZWNvbmQgPSBpOwoJCX0KCQlzb3J0KGEsIGEgKyBuKTsKCQlmb3IgKGludCBpID0gMDsgaSA8IG47ICsraSkgewoJCQlpbnQgY3VyID0gYVtpXS5zZWNvbmQ7CgkJCWlmIChpICsgMSA9PSBuKQoJCQkJc29sW2N1cl0gPSAoYVtpXS5maXJzdCArIGFbbiAtIDJdLmZpcnN0KSAl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