#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
void solve(vector<int> &a) {
int n = a.size();
vector<int> p(n);
int mex = n;
for (int i = n - 1; i >= 0; i--) {
p[i] = mex - a[i];
mex = min(mex, p[i]);
}
for (int i = 0; i < n; i++) {
cout << p[i] << " ";
}
cout << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
for (int zz = 0; zz < t; zz++) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
solve(a);
}
return 0;
}