#include<bits/stdc++.h>
#define ll long long
using namespace std;
int cnt[300005],s[300005],odd[300005],even[300005];
ll read() {
	char c=getchar(); ll x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
long long solve(int l,int r) {
	if (l>=r) return 0;
	int mx=0,j;
	for (int i=l; i<=r; i++) {
		if (mx<cnt[i]) {
			mx=cnt[i];
			j=i;
		}
	}
	long long res=solve(l,j-1)+solve(j+1,r);
	int k;
	if (j-l>=70) {
		k=j-70;
		res+=1LL*(odd[k]-odd[l-1])*(odd[r+1]-odd[j]);
		res+=1LL*(even[k]-even[l-1])*(even[r+1]-even[j]);
		++k;
	}
	else k=l;
	int t=k,sum=cnt[k];
	for (int i=k; i<=j; i++) {
		while (t<j || (t<r && sum<mx*2)) {
			++t;
			sum+=cnt[t];
		}
		if (sum>=mx*2) {
			if (s[i-1]&1) res+=odd[r+1]-odd[t];
			else res+=even[r+1]-even[t];
		}
		sum-=cnt[i];
	}
	return res;
}
int main() {
	ll n=read();
	s[0]=0;
	for (int i=1; i<=n; i++) {
		ll a=read();
		cnt[i]=0;
		while (a>0) {
			if (a&1) ++cnt[i];
			a>>=1;
		}
		s[i]=s[i-1]+cnt[i];
	}
	odd[0]=even[0]=0;
	for (int i=0; i<=n; i++) {
		odd[i+1]=odd[i];
		even[i+1]=even[i];
		if (s[i]&1) ++odd[i+1];
		else ++even[i+1];
	}
	printf("%I64d\n", solve(1,n));
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int cnt[300005],s[300005],odd[300005],even[300005];
ll read() {
	char c=getchar(); ll x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
long long solve(int l,int r) {
	if (l>=r) return 0;
	int mx=0,j;
	for (int i=l; i<=(l+r)/2; i++) {
		if (mx<=cnt[i]) {
			mx=cnt[i];
			j=i;
		}
		if (mx<=cnt[r-i+l]) {
			mx=cnt[r-i+l];
			j=i;
		}
	}
	long long res=solve(l,j-1)+solve(j+1,r);
	int k;
	if (j-l>=70) {
		k=j-70;
		res+=1LL*(odd[k]-odd[l-1])*(odd[r+1]-odd[j]);
		res+=1LL*(even[k]-even[l-1])*(even[r+1]-even[j]);
		++k;
	}
	else k=l;
	int t=k,sum=cnt[k];
	for (int i=k; i<=j; i++) {
		while (t<j || (t<r && sum<mx*2)) {
			++t;
			sum+=cnt[t];
		}
		if (sum>=mx*2) {
			if (s[i-1]&1) res+=odd[r+1]-odd[t];
			else res+=even[r+1]-even[t];
		}
		sum-=cnt[i];
	}
	return res;
}
int main() {
	ll n=read();
	s[0]=0;
	for (int i=1; i<=n; i++) {
		ll a=read();
		cnt[i]=0;
		while (a>0) {
			if (a&1) ++cnt[i];
			a>>=1;
		}
		s[i]=s[i-1]+cnt[i];
	}
	odd[0]=even[0]=0;
	for (int i=0; i<=n; i++) {
		odd[i+1]=odd[i];
		even[i+1]=even[i];
		if (s[i]&1) ++odd[i+1];
		else ++even[i+1];
	}
	printf("%I64d\n", solve(1,n));
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int cnt[300005],s[300005],odd[300005],even[300005];
ll read() {
	char c=getchar(); ll x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
long long solve(int l,int r) {
	if (l>=r) return 0;
	int mx=0,j;
	for (int i=l; i<=(l+r)/2; i++) {
		if (mx<=cnt[i]) {
			mx=cnt[i];
			j=i;
		}
		if (mx<=cnt[r-i+l]) {
			mx=cnt[r-i+l];
			j=r-i+l;
		}
	}
	long long res=solve(l,j-1)+solve(j+1,r);
	int k;
	if (j-l>=70) {
		k=j-70;
		res+=1LL*(odd[k]-odd[l-1])*(odd[r+1]-odd[j]);
		res+=1LL*(even[k]-even[l-1])*(even[r+1]-even[j]);
		++k;
	}
	else k=l;
	int t=k,sum=cnt[k];
	for (int i=k; i<=j; i++) {
		while (t<j || (t<r && sum<mx*2)) {
			++t;
			sum+=cnt[t];
		}
		if (sum>=mx*2) {
			if (s[i-1]&1) res+=odd[r+1]-odd[t];
			else res+=even[r+1]-even[t];
		}
		sum-=cnt[i];
	}
	return res;
}
int main() {
	ll n=read();
	s[0]=0;
	for (int i=1; i<=n; i++) {
		ll a=read();
		cnt[i]=0;
		while (a>0) {
			if (a&1) ++cnt[i];
			a>>=1;
		}
		s[i]=s[i-1]+cnt[i];
	}
	odd[0]=even[0]=0;
	for (int i=0; i<=n; i++) {
		odd[i+1]=odd[i];
		even[i+1]=even[i];
		if (s[i]&1) ++odd[i+1];
		else ++even[i+1];
	}
	printf("%I64d\n", solve(1,n));
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define ri register int
#define maxn 300100
using namespace std;
int n;
LL arr[maxn];
int a[maxn];
int sum[maxn];
int Max[maxn][22];
int ji[maxn], ou[maxn];
int getm(int l, int r)
{
	int len = r - l + 1;
	int t = log2(len);
	if(1 << t > len)
		t --;
	return max(Max[l][t], Max[r - (1 << t) + 1][t]);
}
int gets(int l, int r)
{
	return sum[r] - sum[l - 1];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> arr[i];
	for(int i = 1; i <= n; i ++)
		a[i] = __builtin_popcountll(arr[i]);
//	for(int i = 1; i <= n; i ++)
//		cerr << a[i] << ' ';
//	cerr << endl;
	for(int i = 1; i <= n; i ++)
	{
		sum[i] = sum[i - 1] + a[i];
		Max[i][0] = a[i];
	}
	for(int i = 1; i <= 20; i ++)
	{
		for(int j = 1; j <= n; j ++)
			if(j + (1 << i - 1) <= n)
				Max[j][i] = max(Max[j][i - 1], Max[j + (1 << i - 1)][i - 1]);
	}
	for(int i = 1; i <= n; i ++)
	{
		ji[i] = ji[i - 1];
		ou[i] = ou[i - 1];
		if(a[i] & 1)
			ji[i] ++;
		else
			ou[i] ++;
	}
	LL Ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		int risk = max(i - 64, 0);
		for(int j = risk; j < i; j ++)
		{
			if((sum[j] & 1) == (sum[i] & 1) && getm(j + 1, i) * 2 <= gets(j + 1, i))
			{
//				cerr << j << endl;
				Ans ++;
			}
		}
		if(!risk)
			continue;
		if(sum[i] & 1)
			Ans += ji[risk - 1];
		else
			Ans += ou[risk - 1];
//		cerr << i << ' ' << Ans << endl;
	}
	cout << Ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define ri register int
#define maxn 300100
using namespace std;
int n;
LL arr[maxn];
int a[maxn];
int sum[maxn];
int Max[maxn][22];
int ji[maxn], ou[maxn];
int getm(int l, int r)
{
	int len = r - l + 1;
	int t = log2(len);
	if(1 << t > len)
		t --;
	return max(Max[l][t], Max[r - (1 << t) + 1][t]);
}
int gets(int l, int r)
{
	return sum[r] - sum[l - 1];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> arr[i];
	for(int i = 1; i <= n; i ++)
		a[i] = __builtin_popcountll(arr[i]);
	for(int i = 1; i <= n; i ++)
		cerr << a[i] << ' ';
	cerr << endl;
	for(int i = 1; i <= n; i ++)
	{
		sum[i] = sum[i - 1] + a[i];
		Max[i][0] = a[i];
	}
	for(int i = 1; i <= 20; i ++)
	{
		for(int j = 1; j <= n; j ++)
			if(j + (1 << i - 1) <= n)
				Max[j][i] = max(Max[j][i - 1], Max[j + (1 << i - 1)][i - 1]);
	}
	for(int i = 1; i <= n; i ++)
	{
		ji[i] = ji[i - 1];
		ou[i] = ou[i - 1];
		if(sum[i] & 1)
			ji[i] ++;
		else
			ou[i] ++;
	}
	LL Ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		int risk = max(i - 65, 0);
		for(int j = risk; j < i; j ++)
		{
			if((sum[j] & 1) == (sum[i] & 1) && getm(j + 1, i) * 2 <= gets(j + 1, i))
			{
//				cerr << j << endl;
				Ans ++;
			}
		}
//		cerr << i << ' ' << Ans << endl;
		if(!risk)
			continue;
		if(sum[i] & 1)
			Ans += ji[risk - 1];
		else
			Ans += ou[risk - 1];
//
	}
	cout << Ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define ri register int
#define maxn 300100
using namespace std;
int n;
LL arr[maxn];
int a[maxn];
int sum[maxn];
int Max[maxn][22];
int ji[maxn], ou[maxn];
int getm(int l, int r)
{
	int len = r - l + 1;
	int t = log2(len);
	if(1 << t > len)
		t --;
	return max(Max[l][t], Max[r - (1 << t) + 1][t]);
}
int gets(int l, int r)
{
	return sum[r] - sum[l - 1];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> arr[i];
	for(int i = 1; i <= n; i ++)
		a[i] = __builtin_popcountll(arr[i]);
//	for(int i = 1; i <= n; i ++)
//		cerr << a[i] << ' ';
//	cerr << endl;
	for(int i = 1; i <= n; i ++)
	{
		sum[i] = sum[i - 1] + a[i];
		Max[i][0] = a[i];
	}
	for(int i = 1; i <= 20; i ++)
	{
		for(int j = 1; j <= n; j ++)
			if(j + (1 << i - 1) <= n)
				Max[j][i] = max(Max[j][i - 1], Max[j + (1 << i - 1)][i - 1]);
	}
	ou[0] = 1;
	for(int i = 1; i <= n; i ++)
	{
		ji[i] = ji[i - 1];
		ou[i] = ou[i - 1];
		if(sum[i] & 1)
			ji[i] ++;
		else
			ou[i] ++;
	}
	LL Ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		int risk = max(i - 65, 0);
		for(int j = risk; j < i; j ++)
		{
			if((sum[j] & 1) == (sum[i] & 1) && getm(j + 1, i) * 2 <= gets(j + 1, i))
			{
//				cerr << j << endl;
				Ans ++;
			}
		}
//		cerr << i << ' ' << Ans << endl;
		if(!risk)
			continue;
		if(sum[i] & 1)
			Ans += ji[risk - 1];
		else
			Ans += ou[risk - 1];
//
	}
	cout << Ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
typedef long long LL;
typedef double ld;
typedef pair<int,int> pii;
inline int Gcd(int X,int Y){return Y?Gcd(Y,X%Y):X;}
inline LL Gcd(LL X,LL Y){return Y?Gcd(Y,X%Y):X;}
inline int Pow(int B,LL E,int M){if(!(B%=M))return 0;int A=1;for(;E;E>>=1,B=(LL)B*B%M)E&1?A=(LL)A*B%M:0;return A;}
inline LL Pow(LL base,LL exp,LL _mod){if(!(base%=_mod))return 0;LL _ans=1;for(;exp;exp>>=1,base=base*base%_mod)exp&1?_ans=_ans*base%_mod:0;return _ans;}
const int INF=0x3f3f3f3f;

int n;
int a[300001];
int f[300005];
LL Ans;

int main(){
	LL x;
	scanf("%d",&n);
	F(i,1,n) scanf("%lld",&x), a[i]=__builtin_popcountll(x);
	dF(i,n,1) f[i]=f[i+1]+(a[i]&1);
	F(i,1,n){
		int S=0, Max=0;
		int O=f[i]&1;
		int Sum=0;
		F(j,i,n){
			S+=a[j], Max=max(Max,a[j]);
			if(S>=118) {Sum+=(O?f[j]:n-j+1-f[j]); break;}
			if(Max+Max<=S&&(f[j+1]&1)==O) ++Sum;
		}
		Ans+=Sum;
	} printf("%lld\n",Ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
typedef long long LL;
typedef double ld;
typedef pair<int,int> pii;
inline int Gcd(int X,int Y){return Y?Gcd(Y,X%Y):X;}
inline LL Gcd(LL X,LL Y){return Y?Gcd(Y,X%Y):X;}
inline int Pow(int B,LL E,int M){if(!(B%=M))return 0;int A=1;for(;E;E>>=1,B=(LL)B*B%M)E&1?A=(LL)A*B%M:0;return A;}
inline LL Pow(LL base,LL exp,LL _mod){if(!(base%=_mod))return 0;LL _ans=1;for(;exp;exp>>=1,base=base*base%_mod)exp&1?_ans=_ans*base%_mod:0;return _ans;}
const int INF=0x3f3f3f3f;

int n;
int a[300001];
int s[300001],f[300005];
LL Ans;

int main(){
	LL x;
	scanf("%d",&n);
	F(i,1,n) scanf("%lld",&x), a[i]=__builtin_popcount(x);
	F(i,1,n) s[i]=s[i-1]^(a[i]&1);
	dF(i,n,1) f[i]=f[i+1]^(a[i]&1);
	F(i,1,n){
		int S=0, Max=0;
		int O=s[i-1];
		int Sum=0;
		F(j,i,n){
			S+=a[j], Max=max(Max,a[j]);
			if(S>=118) {Sum+=O?f[j]:n-j+1-f[j]; break;}
			if(Max+Max<=S&&s[j]==O) ++Sum;
		}
		Ans+=Sum;
	} printf("%lld\n",Ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
typedef long long LL;

int n;
int a[300005];
int f[300005];
LL Ans;

int main(){
	LL x;
	scanf("%d",&n);
	F(i,1,n){
		scanf("%lld",&x);
		while(x) x-=x&-x, ++a[i];
	}
	dF(i,n,1) f[i]=f[i+1]+(a[i]&1);
	F(i,1,n){
		int S=0, Max=0;
		int O=f[i]&1;
		int Sum=0;
		F(j,i,n){
			S+=a[j], Max=max(Max,a[j]);
			if(S>=130) {Sum+=(O?f[j+1]:n-j+1-f[j+1]); break;}
			if(Max+Max<=S&&(f[j+1]&1)==O) ++Sum;
		}
		Ans+=Sum;
	} printf("%lld\n",Ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
typedef long long LL;
typedef double ld;
typedef pair<int,int> pii;
inline int Gcd(int X,int Y){return Y?Gcd(Y,X%Y):X;}
inline LL Gcd(LL X,LL Y){return Y?Gcd(Y,X%Y):X;}
inline int Pow(int B,LL E,int M){if(!(B%=M))return 0;int A=1;for(;E;E>>=1,B=(LL)B*B%M)E&1?A=(LL)A*B%M:0;return A;}
inline LL Pow(LL base,LL exp,LL _mod){if(!(base%=_mod))return 0;LL _ans=1;for(;exp;exp>>=1,base=base*base%_mod)exp&1?_ans=_ans*base%_mod:0;return _ans;}
const int INF=0x3f3f3f3f;

int n;
int a[300001];
int f[300005];
LL Ans;

int main(){
	LL x;
	scanf("%d",&n);
	F(i,1,n) scanf("%lld",&x), a[i]=__builtin_popcount(x);
	dF(i,n,1) f[i]=f[i+1]+(a[i]&1);
	F(i,1,n){
		int S=0, Max=0;
		int O=f[i]&1;
		int Sum=0;
		F(j,i,n){
			S+=a[j], Max=max(Max,a[j]);
			if(S>=118) {Sum+=(O?f[j]:n-j+1-f[j]); break;}
			if(Max+Max<=S&&(f[j+1]&1)==O) ++Sum;
		}
		Ans+=Sum;
	} printf("%lld\n",Ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
typedef long long LL;
typedef double ld;
typedef pair<int,int> pii;
inline int Gcd(int X,int Y){return Y?Gcd(Y,X%Y):X;}
inline LL Gcd(LL X,LL Y){return Y?Gcd(Y,X%Y):X;}
inline int Pow(int B,LL E,int M){if(!(B%=M))return 0;int A=1;for(;E;E>>=1,B=(LL)B*B%M)E&1?A=(LL)A*B%M:0;return A;}
inline LL Pow(LL base,LL exp,LL _mod){if(!(base%=_mod))return 0;LL _ans=1;for(;exp;exp>>=1,base=base*base%_mod)exp&1?_ans=_ans*base%_mod:0;return _ans;}
const int INF=0x3f3f3f3f;

int n;
int a[300001];
int f[300005];
LL Ans;

int main(){
	LL x;
	scanf("%d",&n);
	F(i,1,n) scanf("%lld",&x), a[i]=__builtin_popcountll(x);
	dF(i,n,1) f[i]=f[i+1]+(a[i]&1);
	F(i,1,n){
		int S=0, Max=0;
		int O=f[i]&1;
		int Sum=0;
		F(j,i,n){
			S+=a[j], Max=max(Max,a[j]);
			if(S>=118) {Sum+=(O?f[j+1]:n-j+1-f[j+1]); break;}
			if(Max+Max<=S&&(f[j+1]&1)==O) ++Sum;
		}
		Ans+=Sum;
	} printf("%lld\n",Ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
typedef long long LL;

int n;
LL a[500005], f[500005], s[500005], Ans;

int main(){
	LL x;
	scanf("%d",&n);
	F(i,1,n){
		scanf("%lld",&x);
		while(x) x-=x&-x, ++a[i];
	}
	dF(i,n,1) f[i]=f[i+1]+(a[i]&1);
	dF(i,n,1) s[i]=s[i+1]+(f[i]&1);
	F(i,1,n){
		LL S=0, Max=0;
		int O=f[i]&1;
		LL Sum=0;
		F(j,i,n){
			S+=a[j], Max=max(Max,a[j]);
			if(S>=130) {Sum+=(O==1?(s[j+1]):(n-j+1-s[j+1])); break;}
			if(Max+Max<=S&&(f[j+1]&1)==O) ++Sum;
		}
		Ans+=Sum;
	} printf("%lld\n",Ans);
	return 0;
}


#include<bits/stdc++.h>

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double lf;
typedef long double llf;
typedef std::pair<int,int> pii;

#define xx first
#define yy second

template<typename T> inline T max(T a,T b){return a>b?a:b;}
template<typename T> inline T min(T a,T b){return a<b?a:b;}
template<typename T> inline T abs(T a){return a>0?a:-a;}
template<typename T> inline bool repr(T &a,T b){return a<b?a=b,1:0;}
template<typename T> inline bool repl(T &a,T b){return a>b?a=b,1:0;}
template<typename T> inline T gcd(T a,T b){T t;if(a<b){while(a){t=a;a=b%a;b=t;}return b;}else{while(b){t=b;b=a%b;a=t;}return a;}}
template<typename T> inline T sqr(T x){return x*x;}
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
#define I inline
#define mset(a,b) memset(a,b,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))

#define fo0(i,n) for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define fd0(i,n) for(int i=(n)-1;~i;i--)
#define fd1(i,n) for(int i=n;i;i--)
#define fd(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define foe(i,x)for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)

struct Cg{I char operator()(){return getchar();}};
struct Cp{I void operator()(char x){putchar(x);}};
#define OP operator
#define RT return *this;
#define UC unsigned char
#define RX x=0;UC t=P();while((t<'0'||t>'9')&&t!='-')t=P();bool f=0;\
if(t=='-')t=P(),f=1;x=t-'0';for(t=P();t>='0'&&t<='9';t=P())x=x*10+t-'0'
#define RL if(t=='.'){lf u=0.1;for(t=P();t>='0'&&t<='9';t=P(),u*=0.1)x+=u*(t-'0');}if(f)x=-x
#define RU x=0;UC t=P();while(t<'0'||t>'9')t=P();x=t-'0';for(t=P();t>='0'&&t<='9';t=P())x=x*10+t-'0'
#define TR *this,x;return x;
I bool IS(char x){return x==10||x==13||x==' ';}template<typename T>struct Fr{T P;I Fr&OP,(int&x)
{RX;if(f)x=-x;RT}I OP int(){int x;TR}I Fr&OP,(ll &x){RX;if(f)x=-x;RT}I OP ll(){ll x;TR}I Fr&OP,(char&x)
{for(x=P();IS(x);x=P());RT}I OP char(){char x;TR}I Fr&OP,(char*x){char t=P();for(;IS(t);t=P());if(~t){for(;!IS
(t)&&~t;t=P())*x++=t;}*x++=0;RT}I Fr&OP,(lf&x){RX;RL;RT}I OP lf(){lf x;TR}I Fr&OP,(llf&x){RX;RL;RT}I OP llf()
{llf x;TR}I Fr&OP,(uint&x){RU;RT}I OP uint(){uint x;TR}I Fr&OP,(ull&x){RU;RT}I OP ull(){ull x;TR}};Fr<Cg>in;
#define WI(S) if(x){if(x<0)P('-'),x=-x;UC s[S],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
#define WL if(y){lf t=0.5;for(int i=y;i--;)t*=0.1;if(x>=0)x+=t;else x-=t,P('-');*this,(ll)(abs(x));P('.');if(x<0)\
x=-x;while(y--){x*=10;x-=floor(x*0.1)*10;P(((int)x)%10+'0');}}else if(x>=0)*this,(ll)(x+0.5);else *this,(ll)(x-0.5);
#define WU(S) if(x){UC s[S],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
template<typename T>struct Fw{T P;I Fw&OP,(int x){WI(10);RT}I Fw&OP()(int x){WI(10);RT}I Fw&OP,(uint x){WU(10);RT}
I Fw&OP()(uint x){WU(10);RT}I Fw&OP,(ll x){WI(19);RT}I Fw&OP()(ll x){WI(19);RT}I Fw&OP,(ull x){WU(20);RT}I Fw&OP()
(ull x){WU(20);RT}I Fw&OP,(char x){P(x);RT}I Fw&OP()(char x){P(x);RT}I Fw&OP,(const char*x){while(*x)P(*x++);RT}
I Fw&OP()(const char*x){while(*x)P(*x++);RT}I Fw&OP()(lf x,int y){WL;RT}I Fw&OP()(llf x,int y){WL;RT}};Fw<Cp>out;

const int N=300007,M=128;

int n,s[N],pre[N],f[N];

int main()
{
	in,n;
	fo1(i,n)
	{
		s[i]=__builtin_popcountll((ll)in);
	}
	int t=0;
	fo1(i,n)
	{
		t=t+s[i]&1;
		pre[i]=pre[i-1]+t;
		f[i]=t;
	}
	ll ans=0;
	fo1(i,n)
	{
		int su=0,ma=0,j=i;
		while(j>=i-M&&j>=1)
		{
			su+=s[j];
			repr(ma,s[j]);
			if(ma*2<=su&&(~su&1))ans++;
			j--;
		}
		ans+=f[i]?pre[j]:j-pre[j];
	}
	out,ans,'\n';
}


// Author : Ritik Patel
// Institution: Pandit Deendayal Petroleum University

#include <bits/stdc++.h>
using namespace std;

#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define what_is(x) cerr << #x << " is " << x << endl;
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)

#define bitcount(a) __builtin_popcount(a)   // count set bits
#define lzcount(x) __builtin_clz(x)        // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x)        // count trailing zeros in binary representation of number

#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

typedef long long ll;
typedef long double lld;
const ll MOD = 1e9+7;
const lld PI = acos(-1.0);

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
template<typename T> inline string toStr(T x) { stringstream st; st << x; string s; st >> s; return s; }

bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;}
//Fermat little theorem -> a^(M-1) % M = 1; iF M is prime
// Multilply both sides by a^-1 ==> a^(M-2)%M = a^-1
template<typename T>//(a/b)%MD IFF MD -> PRIME
T modDiv(T a,T b,T MD){   return a*fast_power(b,MD-2,MD) % MD; }
template<typename T>
T extgcd(T a, T b, T &x, T &y) {  //when a and b are coprimes(or gcd(a,b)==1) in ax+by = t*gcd(a,b);
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}
ll inv(ll a, ll m) { ll x, y;  extgcd(a, m, x, y);  return (x + m) % m; } //IFF GCD(a,m) = 1;

template<typename T>
T largestPower(T n,T p){        // Returns largest power of p that divides n!
    T total = 0;
    while (n){                  // Calculate x = n/p + n/(p^2) + n/(p^3) + ...
        n /= p;
        total += n;
    }
    return total;
}

int doublecomp(double a, double b){
    if( (a-b) <= 0.0000000001 ) return 1; // a <= b;
    else  return 0;
}

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const int INF = 1<<30;
const ll LINF = 1ll<<60;

/*-> For counting number of digits, directly do floor(log10(n)+1)
  -> Whenever comparing fractions, it is better to cross-multiply so we can avoid the use of doubles
  ->
*/
               /* -------------------------------Main Code------------------------------- */

vi mark((int)1e5 + 5);
int main (){
    FAST
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        vi q(n);
        for(int i = 0; i < n; ++i){
            cin >> q[i];
        }
        int elem = -1;
        int poss = 1;
        for(int i = 1; i < n - 1; ++i){
            if(q[i] - q[i-1] > 1){
                elem = q[i] + 1;
            }
            else if(q[i] == q[i-1] && elem == -1){
                poss = 0; break;
            }
        }
        if( n >= 2 && q[n-1] == q[n-2] && q[n-1] != n){
            poss = 0;
        }
        if(!poss) cout << -1 << '\n';
        else{

            if(q[0] != 1){
                elem = 1;
            } else {
                for(int i = 0; i < n-1 ; ++i){
                    if(q[i+1] - q[i] > 1){
                        elem = q[i]+1;
                        break;
                    }
                }
            }
            cout << q[0] << " ";
            mark[q[0]] = 1;
            for(int i = 1; i < n; ++i){
                if(q[i] == q[i-1]){
                    for(int j = 1; j <= n; ++j){
                        if(!mark[j]){
                            cout << j << " ";
                            mark[j] = 1;
                            break;
                        }
                    }
                } else {
                    mark[q[i]] = 1;
                    cout << q[i] << " ";
                }
            }
            cout << '\n';
        }
        fill(all(mark) ,0 );
    }
    return 0;
}


// Author : Ritik Patel
// Institution: Pandit Deendayal Petroleum University

#include <bits/stdc++.h>
using namespace std;

#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define what_is(x) cerr << #x << " is " << x << endl;
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)

#define bitcount(a) __builtin_popcount(a)   // count set bits
#define lzcount(x) __builtin_clz(x)        // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x)        // count trailing zeros in binary representation of number

#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

typedef long long ll;
typedef long double lld;
const ll MOD = 1e9+7;
const lld PI = acos(-1.0);

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
template<typename T> inline string toStr(T x) { stringstream st; st << x; string s; st >> s; return s; }

bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;}
//Fermat little theorem -> a^(M-1) % M = 1; iF M is prime
// Multilply both sides by a^-1 ==> a^(M-2)%M = a^-1
template<typename T>//(a/b)%MD IFF MD -> PRIME
T modDiv(T a,T b,T MD){   return a*fast_power(b,MD-2,MD) % MD; }
template<typename T>
T extgcd(T a, T b, T &x, T &y) {  //when a and b are coprimes(or gcd(a,b)==1) in ax+by = t*gcd(a,b);
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}
ll inv(ll a, ll m) { ll x, y;  extgcd(a, m, x, y);  return (x + m) % m; } //IFF GCD(a,m) = 1;

template<typename T>
T largestPower(T n,T p){        // Returns largest power of p that divides n!
    T total = 0;
    while (n){                  // Calculate x = n/p + n/(p^2) + n/(p^3) + ...
        n /= p;
        total += n;
    }
    return total;
}

int doublecomp(double a, double b){
    if( (a-b) <= 0.0000000001 ) return 1; // a <= b;
    else  return 0;
}

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const int INF = 1<<30;
const ll LINF = 1ll<<60;

/*-> For counting number of digits, directly do floor(log10(n)+1)
  -> Whenever comparing fractions, it is better to cross-multiply so we can avoid the use of doubles
  ->
*/
               /* -------------------------------Main Code------------------------------- */

int main (){
    FAST
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        vi q(n);
        for(int i = 0; i < n; ++i){
            cin >> q[i];
        }
        int poss = 1;
        for(int i = 1; i < n - 1; ++i){
            if(q[i] == q[i-1]){
                poss = 0; break;
            }
        }
        if( n >= 2 && q[n-1] == q[n-2] && q[n-1] != n){
            poss = 0;
        }
        if(!poss) cout << -1 << '\n';
        else{
            int elem = -1;
            if(q[0] != 1){
                elem = 1;
            } else {
                for(int i = 0; i < n-1 ; ++i){
                    if(q[i+1] - q[i] > 1){
                        elem = q[i]+1;
                        break;
                    }
                }
            }
            cout << q[0] << " ";
            for(int i = 1; i < n; ++i){
                if(q[i] == q[i-1]){
                    if(elem == -1) cout << n + elem << " ";
                    else cout << elem << " ";
                } else {
                    cout << q[i] << " ";
                }
            }
            cout << '\n';
        }
    }
    return 0;
}


// Author : Ritik Patel
// Institution: Pandit Deendayal Petroleum University

#include <bits/stdc++.h>
using namespace std;

#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define what_is(x) cerr << #x << " is " << x << endl;
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)

#define bitcount(a) __builtin_popcount(a)   // count set bits
#define lzcount(x) __builtin_clz(x)        // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x)        // count trailing zeros in binary representation of number

#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

typedef long long ll;
typedef long double lld;
const ll MOD = 1e9+7;
const lld PI = acos(-1.0);

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
template<typename T> inline string toStr(T x) { stringstream st; st << x; string s; st >> s; return s; }

bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;}
//Fermat little theorem -> a^(M-1) % M = 1; iF M is prime
// Multilply both sides by a^-1 ==> a^(M-2)%M = a^-1
template<typename T>//(a/b)%MD IFF MD -> PRIME
T modDiv(T a,T b,T MD){   return a*fast_power(b,MD-2,MD) % MD; }
template<typename T>
T extgcd(T a, T b, T &x, T &y) {  //when a and b are coprimes(or gcd(a,b)==1) in ax+by = t*gcd(a,b);
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}
ll inv(ll a, ll m) { ll x, y;  extgcd(a, m, x, y);  return (x + m) % m; } //IFF GCD(a,m) = 1;

template<typename T>
T largestPower(T n,T p){        // Returns largest power of p that divides n!
    T total = 0;
    while (n){                  // Calculate x = n/p + n/(p^2) + n/(p^3) + ...
        n /= p;
        total += n;
    }
    return total;
}

int doublecomp(double a, double b){
    if( (a-b) <= 0.0000000001 ) return 1; // a <= b;
    else  return 0;
}

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const int INF = 1<<30;
const ll LINF = 1ll<<60;

/*-> For counting number of digits, directly do floor(log10(n)+1)
  -> Whenever comparing fractions, it is better to cross-multiply so we can avoid the use of doubles
  ->
*/
               /* -------------------------------Main Code------------------------------- */

int main (){
    FAST
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        vi q(n);
        for(int i = 0; i < n; ++i){
            cin >> q[i];
        }
        int poss = 1;
        for(int i = 1; i < n - 1; ++i){
            if(q[i] == q[i-1]){
                poss = 0; break;
            }
        }
        if( n >= 2 && q[n-1] == q[n-2] && q[n-1] != n){
            poss = 0;
        }
        if(!poss) cout << -1 << '\n';
        else{
            int elem = -1;
            for(int i = 0; i < n-1 ; ++i){
                if(q[i+1] - q[i] > 1){
                    elem = q[i]+1;
                    break;
                }
            }
            cout << q[0] << " ";
            for(int i = 1; i < n; ++i){
                if(q[i] == q[i-1]){
                    if(elem == -1) cout << n + elem << " ";
                    else cout << elem << " ";
                } else {
                    cout << q[i] << " ";
                }
            }
            cout << '\n';
        }
    }
    return 0;
}


// Author : Ritik Patel
// Institution: Pandit Deendayal Petroleum University

#include <bits/stdc++.h>
using namespace std;

#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define what_is(x) cerr << #x << " is " << x << endl;
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)

#define bitcount(a) __builtin_popcount(a)   // count set bits
#define lzcount(x) __builtin_clz(x)        // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x)        // count trailing zeros in binary representation of number

#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

typedef long long ll;
typedef long double lld;
const ll MOD = 1e9+7;
const lld PI = acos(-1.0);

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
template<typename T> inline string toStr(T x) { stringstream st; st << x; string s; st >> s; return s; }

bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;}
//Fermat little theorem -> a^(M-1) % M = 1; iF M is prime
// Multilply both sides by a^-1 ==> a^(M-2)%M = a^-1
template<typename T>//(a/b)%MD IFF MD -> PRIME
T modDiv(T a,T b,T MD){   return a*fast_power(b,MD-2,MD) % MD; }
template<typename T>
T extgcd(T a, T b, T &x, T &y) {  //when a and b are coprimes(or gcd(a,b)==1) in ax+by = t*gcd(a,b);
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}
ll inv(ll a, ll m) { ll x, y;  extgcd(a, m, x, y);  return (x + m) % m; } //IFF GCD(a,m) = 1;

template<typename T>
T largestPower(T n,T p){        // Returns largest power of p that divides n!
    T total = 0;
    while (n){                  // Calculate x = n/p + n/(p^2) + n/(p^3) + ...
        n /= p;
        total += n;
    }
    return total;
}

int doublecomp(double a, double b){
    if( (a-b) <= 0.0000000001 ) return 1; // a <= b;
    else  return 0;
}

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const int INF = 1<<30;
const ll LINF = 1ll<<60;

/*-> For counting number of digits, directly do floor(log10(n)+1)
  -> Whenever comparing fractions, it is better to cross-multiply so we can avoid the use of doubles
  ->
*/
               /* -------------------------------Main Code------------------------------- */

int main (){
    FAST
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        vi q(n);
        for( int i = 0; i < n ; ++i) cin >> q[i];
        stack <int> s;
        for(int j = 1; j < q[0] ; ++j){
            s.push(j);
        }
        vi ans(n);
        ans[0] = q[0];
        int poss = 1;
        for(int i = 1; i < n; ++i){
            if(q[i] != q[i-1]){
                ans[i] = q[i];
                for(int j = q[i-1]+1 ; j < q[i]; ++j){
                    s.push(j);
                }
            } else{
                if(s.empty()) {poss = 0;break;}
                int tp = s.top();
                s.pop();
                ans[i]  = tp;
            }
        }
        if(!poss) cout << -1 << '\n';
        else{
            for(auto i:ans) cout << i << " ";
            cout << '\n';
        }

    }
    return 0;
}


#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;

const int N = 1e5 + 10;

int main() {
    fast_cin();

    int t=1;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        int a[N];
        for (int i=1; i <= n; i++) cin >> a[i];

        int ans[n+1];
        bool visited[n+1];

        for (int i=2; i <= n; i++) {
            visited[i] = false;
            ans[i] = 0;
        }

        ans[1] = a[1];
        visited[ans[1]] = true;

        for (int i=2; i <= n; i++) {

            if (a[i] != a[i-1]) {
                ans[i] = a[i];
                visited[ans[i]]= true;
            }
        }

        // for (int i=1; i <= n; i++) {
        //     cout << visited[i] << ' ';
        // }

        int j=1;
        int  flag = 1;
        for (int i=1; i <= n; i++) {
            if (ans[i] != a[i]) {
                for (; j <= n; j++) {
                    if  (visited[j] != true) {
                        if (j > a[i]) {
                            flag  =0;
                            break;
                        }
                        else {
                            ans[i] = j;
                        }
                    }
                }
                if (flag == 0) break;
            }
        }

        for (int i=1; i <= n; i++) {
            if (ans[i] == 0) {
                flag = 0;
                break;
            }
        }

        if (flag) {
            for (int i=1; i <= n; i++) {
                cout << ans[i] << ' ';
            }
            cout << '\n';
        }
        else cout << "-1\n";
    }
}


#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;

const int N = 1e5 + 10;

int main() {
    fast_cin();

    int t=1;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        int a[N];
        for (int i=1; i <= n; i++) cin >> a[i];

        int ans[n+1];
        bool visited[n+1];

        for (int i=2; i <= n; i++) {
            visited[i] = false;
            ans[i] = 0;
        }

        ans[1] = a[1];
        visited[ans[1]] = true;

        for (int i=2; i <= n; i++) {

            if (a[i] != a[i-1]) {
                ans[i] = a[i];
                visited[ans[i]]= true;
            }
        }

        // for (int i=1; i <= n; i++) {
        //     cout << visited[i] << ' ';
        // }

        int i=1, j=1;
        int  flag = 1;
        for (; i <= n; i++) {
            if (ans[i] != a[i]) {
                for (; j <= n; j++) {
                    if  (visited[j] != true) {
                        if (j > a[i]) {
                            flag  =0;
                            break;
                        }
                        else {
                            ans[i] = j;
                        }
                    }
                }
                if (flag == 0) break;
            }
        }

        for (int i=1; i <= n; i++) {
            if (ans[i] == 0) {
                flag = 0;
                break;
            }
        }

        if (flag) {
            for (int i=1; i <= n; i++) {
                cout << ans[i] << ' ';
            }
            cout << '\n';
        }
        else cout << "-1\n";
    }
}


#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;

const int N = 2e5 + 10;

int main() {
    fast_cin();

    int t=1;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        int a[N];
        for (int i=1; i <= n; i++) cin >> a[i];

        int ans[n+1];
        bool visited[n+1];

        for (int i=2; i <= n; i++) {
            visited[i] = false;
            ans[i] = 0;
        }

        ans[1] = a[1];
        visited[ans[1]] = true;

        for (int i=2; i <= n; i++) {

            if (a[i] != a[i-1]) {
                ans[i] = a[i];
                visited[ans[i]]= true;
            }
        }

        // for (int i=1; i <= n; i++) {
        //     cout << visited[i] << ' ';
        // }

        int i=1, j=1;
        int  flag = 1;
        for (; i <= n; i++) {
            if (ans[i] != a[i]) {
                for (; j <= n; j++) {
                    if  (visited[j] != true) {
                        if (j > a[i]) {
                            flag  =0;
                            break;
                        }
                        else {
                            ans[i] = j;
                        }
                    }
                }
                if (flag == 0) break;
            }
        }

        for (int i=1; i <= n; i++) {
            if (ans[i] == 0) {
                flag = 0;
                break;
            }
        }

        if (flag) {
            for (int i=1; i <= n; i++) {
                cout << ans[i] << ' ';
            }
            cout << '\n';
        }
        else cout << "-1\n";
    }
}


#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;

const int N = 2e5 + 10;

int main() {
    fast_cin();

    int t=1;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        int a[N];
        for (int i=1; i <= n; i++) cin >> a[i];

        int ans[n+1];
        bool visited[n+1];
        ans[1] = a[1];
        visited[ans[1]] = true;

        for (int i=2; i <= n; i++) {
            visited[i] = false;
            ans[i] = 0;
        }

        for (int i=2; i <= n; i++) {

            if (a[i] != a[i-1]) {
                ans[i] = a[i];
                visited[ans[i]]= true;
            }
        }

        // for (int i=1; i <= n; i++) {
        //     cout << visited[i] << ' ';
        // }

        int i=1, j=1;
        int  flag = 1;
        for (; i <= n; i++) {
            if (ans[i] != a[i]) {
                for (; j <= n; j++) {
                    if  (visited[j] != true) {
                        if (j > a[i]) {
                            flag  =0;
                            break;
                        }
                        else {
                            ans[i] = j;
                        }
                    }
                }
                if (flag == 0) break;
            }
        }

        for (int i=1; i <= n; i++) {
            if (ans[i] == 0) {
                flag = 0;
                break;
            }
        }

        if (flag) {
            for (int i=1; i <= n; i++) {
                cout << ans[i] << ' ';
            }
            cout << '\n';
        }
        else cout << "-1\n";
    }
}


#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;

const int N = 1e5 + 10;

int main() {
    fast_cin();

    int t=1;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        int a[N];
        for (int i=1; i <= n; i++) cin >> a[i];

        int ans[n+1];
        bool visited[n+1];

        for (int i=0; i <= n; i++) {
            visited[i] = false;
            ans[i] = 0;
        }

        ans[1] = a[1];
        visited[ans[1]] = true;

        for (int i=2; i <= n; i++) {

            if (a[i] != a[i-1]) {
                ans[i] = a[i];
                visited[ans[i]]= true;
            }
        }

        // for (int i=1; i <= n; i++) {
        //     cout << visited[i] << ' ';
        // }

        int j=1;
        int  flag = 1;
        for (int i=1; i <= n; i++) {
            if (ans[i] != a[i]) {
                for (; j <= n; j++) {
                    if  (visited[j] != true) {
                        if (j > a[i]) {
                            flag  =0;
                            break;
                        }
                        else {
                            ans[i] = j;
                            j++;
                            break;
                        }
                    }
                }
                if (flag == 0) break;
            }
        }

        for (int i=1; i <= n; i++) {
            if (ans[i] == 0) {
                flag = 0;
                break;
            }
        }

        if (flag) {
            for (int i=1; i <= n; i++) {
                cout << ans[i] << ' ';
            }
            cout << '\n';
        }
        else cout << "-1\n";
    }
}


#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;

const int N = 1e5 + 10;

int main() {
    fast_cin();

    int t=1;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        int a[N];
        for (int i=1; i <= n; i++) cin >> a[i];

        int ans[n+1];
        bool visited[n+1];

        for (int i=0; i <= n; i++) {
            visited[i] = false;
            ans[i] = 0;
        }

        ans[1] = a[1];
        visited[ans[1]] = true;

        for (int i=2; i <= n; i++) {

            if (a[i] != a[i-1]) {
                ans[i] = a[i];
                visited[ans[i]]= true;
            }
        }

        // for (int i=1; i <= n; i++) {
        //     cout << visited[i] << ' ';
        // }

        int j=1;
        int  flag = 1;
        for (int i=1; i <= n; i++) {
            if (ans[i] != a[i]) {
                for (; j <= n; j++) {
                    if  (visited[j] != true) {
                        if (j > a[i]) {
                            flag  =0;
                            break;
                        }
                        else {
                            ans[i] = j;
                        }
                    }
                }
                if (flag == 0) break;
            }
        }

        for (int i=1; i <= n; i++) {
            if (ans[i] == 0) {
                flag = 0;
                break;
            }
        }

        if (flag) {
            for (int i=1; i <= n; i++) {
                cout << ans[i] << ' ';
            }
            cout << '\n';
        }
        else cout << "-1\n";
    }
}


    #include <bits/stdc++.h>
    using namespace std;
    #include <ext/pb_ds/assoc_container.hpp> // Include for built in treap
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    const int MOD = 1e9 + 7;
    #define ll long long int
    #define pii pair<int, int>
    #define pll pair<ll, ll>
    #define pb push_back
    #define eb emplace_back
    #define ff first
    #define ss second
    #define vi vector<int>
    #define vl vector<ll>
    #define vpii vector<pii>
    #define vpll vector<pll>
    #define si set<int>
    #define mpii map<int, int>
    #define prq priority_queue
    #define sz(s) (int) s.size()
    #define pf(a) printf("%d\n",a)
    #define si1(a) scanf("%d",&a)
    #define si2(a,b) scanf("%d%d",&a,&b)
    #define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
    #define pi 2 * acos (0.0)
    #define inf 1e9
    #define dbg cout<<"ok"<<endl;
    #define FOR(i, j, k) for(int i=(j); i<(k); i++)
    #define REV(i, j, k) for(int i=(n-1); i>=k; i--)
    #define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
    #define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
    #define mem(x, y) memset(x, y, sizeof(x))
    typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_ds;
    const double EPS = 1e-9;
    const int MXX = 1e6 + 5;

    int a[MXX];
    bool vis[MXX];
    int main()
    {
        FAST_IO;
        int tc;
        cin>>tc;
        while(tc--)
        {
            memset(vis, false,sizeof(vis));
            int n;
            cin>>n;
            si st;
            for(int i = 1; i<=n; i++)st.insert(i);
            vi v;
            FOR(i, 0, n)cin>>a[i];
            FOR(i, 0, n)
            {
                if(!vis[a[i]])
                {
                    v.pb(a[i]);
                    vis[a[i]] = 1;
                    st.erase(a[i]);
                }
                else
                {
                    if(st.size() == 0)continue;
                    auto it = st.begin();
                    v.pb(*it);
                    st.erase(*it);
                    vis[*it] = true;
                }
            }
            bool f = 1;
            if(sz(v)!=n)f=0;
            vi ans;
            ans.pb(v[0]);
            int mx = v[0];
            for(int i = 1; i<n; i++)
            {
                mx = max(v[i], mx);
                ans.pb(mx);
            }

            FOR(i, 0, n)
            {
                if(ans[i]!=a[i])f = 0;
            }
            if(f)
            {
                for(auto x: v)
                {
                    cout<<x<<" ";
                }
                cout<<endl;
            }
            else cout<<-1<<endl;
        }
        return 0;
    }


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Include for built in treap
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d\n",a)
#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pi 2 * acos (0.0)
#define inf 1e9
#define dbg cout<<"ok"<<endl;
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_ds;
const double EPS = 1e-9;
const int MXX = 1e5 + 5;

int a[MXX];
bool vis[MXX];
int main()
{
    FAST_IO;
    int tc;
    cin>>tc;
    while(tc--)
    {
        memset(vis, false,sizeof(vis));
        int n;
        cin>>n;
        si st;
        for(int i = 1; i<=n; i++)st.insert(i);
        vi v;
        FOR(i, 0, n)cin>>a[i];
        FOR(i, 0, n)
        {
            if(!vis[a[i]])
            {
                v.pb(a[i]);
                vis[a[i]] = 1;
                if(sz(st))
                {
                    if(st.find(a[i])!=st.end())st.erase(a[i]);
                }
            }
            else
            {
                if(st.size() == 0)continue;
                auto it = st.begin();
                v.pb(*it);
                st.erase(*it);
                vis[*it] = true;
            }
        }
        bool f = 1;
        if(sz(v)!=n)f=0;
        if(!f)
        {
            cout<<-1<<endl;
            continue;
        }
        vi ans;
        ans.pb(v[0]);
        int mx = v[0];
        for(int i = 1; i<n; i++)
        {
            mx = max(v[i], mx);
            ans.pb(mx);
        }

        FOR(i, 0, n)
        {
            if(ans[i]!=a[i])f = 0;
        }
        if(f)
        {
            for(auto x: v)
            {
                cout<<x<<" ";
            }
            cout<<endl;
        }
        else cout<<-1<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Include for built in treap
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d\n",a)
#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pi 2 * acos (0.0)
#define inf 1e9
#define dbg cout<<"ok"<<endl;
#define FOR(i, j, k) for(ll i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_ds;
const double EPS = 1e-9;
const int MXX = 2e5 + 5;

ll a[MXX];

int main()
{
    FAST_IO;
    int tc;
    cin>>tc;
    while(tc--)
    {
        map<ll, ll>vis;
        ll n;
        cin>>n;
        si st;
        for(ll i = 1; i<=n; i++)st.insert(i);
        vector<ll>v;
        FOR(i, 0, n)cin>>a[i];
        FOR(i, 0, n)
        {
            if(!vis[a[i]])
            {
                v.pb(a[i]);
                vis[a[i]] = 1;
                if(sz(st)!=0)
                {
                    if(st.find(a[i])!=st.end())st.erase(a[i]);
                }
            }
            else
            {
                if(st.size() == 0)continue;
                auto it = st.begin();
                v.pb(*it);
                if(st.size()!=0)st.erase(*it);
                vis[*it] = true;
            }
        }
        bool f = 1;
        if(sz(v)!=n)f=0;
        if(!f)
        {
            cout<<-1<<endl;
            continue;
        }
        vector<ll>ans;
        ans.pb(v[0]);
        ll mx = v[0];
        for(ll i = 1; i<n; i++)
        {
            mx = max(v[i], mx);
            ans.pb(mx);
        }
        if(sz(ans) == n)
        {
            FOR(i, 0, n)
            {
                if(ans[i]!=a[i])f = 0;
            }
        }
        if(f)
        {
            for(auto x: v)
            {
                cout<<x<<" ";
            }
            cout<<endl;
        }
        else cout<<-1<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Include for built in treap
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d\n",a)
#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pi 2 * acos (0.0)
#define inf 1e9
#define dbg cout<<"ok"<<endl;
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_ds;
const double EPS = 1e-9;
const int MXX = 1e5 + 5;

int a[MXX];
bool vis[MXX];
int main()
{
    FAST_IO;
    int tc;
    cin>>tc;
    while(tc--)
    {
        memset(vis, false,sizeof(vis));
        int n;
        cin>>n;
        si st;
        for(int i = 1; i<=n; i++)st.insert(i);
        vi v;
        FOR(i, 0, n)cin>>a[i];
        FOR(i, 0, n)
        {
            if(!vis[a[i]])
            {
                v.pb(a[i]);
                vis[a[i]] = 1;
                if(sz(st)!=0)
                {
                    if(st.find(a[i])!=st.end())st.erase(a[i]);
                }
            }
            else
            {
                if(st.size() == 0)continue;
                auto it = st.begin();
                v.pb(*it);
                if(st.size()!=0)st.erase(*it);
                vis[*it] = true;
            }
        }
        bool f = 1;
        if(sz(v)!=n)f=0;
        if(!f)
        {
            cout<<-1<<endl;
            continue;
        }
        vi ans;
        ans.pb(v[0]);
        int mx = v[0];
        for(int i = 1; i<n; i++)
        {
            mx = max(v[i], mx);
            ans.pb(mx);
        }
        if(sz(ans) == n)
        {
            FOR(i, 0, n)
            {
                if(ans[i]!=a[i])f = 0;
            }
        }
        if(f)
        {
            for(auto x: v)
            {
                cout<<x<<" ";
            }
            cout<<endl;
        }
        else cout<<-1<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Include for built in treap
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
const int MOD = 1e9 + 7;
#define int long long
#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d\n",a)
#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pi 2 * acos (0.0)
#define inf 1e9
#define dbg cout<<"ok"<<endl;
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_ds;
const double EPS = 1e-9;
const int MXX = 1e5 + 5;

int a[MXX];
bool vis[MXX];
main()
{
    FAST_IO;
    int tc;
    cin>>tc;
    while(tc--)
    {
        memset(vis, false,sizeof(vis));
        int n;
        cin>>n;
        si st;
        for(int i = 1; i<=n; i++)st.insert(i);
        vi v;
        FOR(i, 0, n)cin>>a[i];
        FOR(i, 0, n)
        {
            if(!vis[a[i]])
            {
                v.pb(a[i]);
                vis[a[i]] = 1;
                if(sz(st)!=0)
                {
                    if(st.find(a[i])!=st.end())st.erase(a[i]);
                }
            }
            else
            {
                if(st.size() == 0)continue;
                auto it = st.begin();
                v.pb(*it);
                if(st.size()!=0)st.erase(*it);
                vis[*it] = true;
            }
        }
        bool f = 1;
        if(sz(v)!=n)f=0;
        if(!f)
        {
            cout<<-1<<endl;
            continue;
        }
        vi ans;
        ans.pb(v[0]);
        int mx = v[0];
        for(int i = 1; i<n; i++)
        {
            mx = max(v[i], mx);
            ans.pb(mx);
        }
        if(sz(ans) == n)
        {
            FOR(i, 0, n)
            {
                if(ans[i]!=a[i])f = 0;
            }
        }
        if(f)
        {
            for(auto x: v)
            {
                cout<<x<<" ";
            }
            cout<<endl;
        }
        else cout<<-1<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Include for built in treap
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d\n",a)
#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pi 2 * acos (0.0)
#define inf 1e9
#define dbg cout<<"ok"<<endl;
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_ds;
const double EPS = 1e-9;
const int MXX = 1e5 + 5;

int a[MXX];
bool vis[MXX];
int main()
{
    FAST_IO;
    int tc;
    cin>>tc;
    while(tc--)
    {
        memset(vis, false,sizeof(vis));
        int n;
        cin>>n;
        si st;
        for(int i = 1; i<=n; i++)st.insert(i);
        vi v;
        FOR(i, 0, n)cin>>a[i];
        FOR(i, 0, n)
        {
            if(!vis[a[i]])
            {
                v.pb(a[i]);
                vis[a[i]] = 1;
                st.erase(a[i]);
            }
            else
            {
                if(st.size() == 0)continue;
                auto it = st.begin();
                v.pb(*it);
                st.erase(*it);
                vis[*it] = true;
            }
        }
        bool f = 1;
        if(sz(v)!=n)f=0;
        vi ans;
        ans.pb(v[0]);
        int mx = v[0];
        for(int i = 1; i<n; i++)
        {
            mx = max(v[i], mx);
            ans.pb(mx);
        }

        FOR(i, 0, n)
        {
            if(ans[i]!=a[i])f = 0;
        }
        if(f)
        {
            for(auto x: v)
            {
                cout<<x<<" ";
            }
            cout<<endl;
        }
        else cout<<-1<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Include for built in treap
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d\n",a)
#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pi 2 * acos (0.0)
#define inf 1e9
#define dbg cout<<"ok"<<endl;
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_ds;
const double EPS = 1e-9;
const int MXX = 1e5 + 5;

int a[MXX];
bool vis[MXX];
int main()
{
    FAST_IO;
    int tc;
    cin>>tc;
    while(tc--)
    {
        map<int, bool>vis;
        int n;
        cin>>n;
        si st;
        for(int i = 1; i<=n; i++)st.insert(i);
        vi v;
        FOR(i, 0, n)cin>>a[i];
        FOR(i, 0, n)
        {
            if(!vis[a[i]])
            {
                v.pb(a[i]);
                vis[a[i]] = 1;
                st.erase(a[i]);
            }
            else
            {
                if(st.size() == 0)continue;
                auto it = st.begin();
                v.pb(*it);
                st.erase(*it);
                vis[*it] = true;
            }
        }
        bool f = 1;
        if(sz(v)!=n)f=0;
        vi ans;
        ans.pb(v[0]);
        int mx = v[0];
        for(int i = 1; i<n; i++)
        {
            mx = max(v[i], mx);
            ans.pb(mx);
        }

        FOR(i, 0, n)
        {
            if(ans[i]!=a[i])f = 0;
        }
        if(f)
        {
            for(auto x: v)
            {
                cout<<x<<" ";
            }
            cout<<endl;
        }
        else cout<<-1<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define N 1000000007;
using namespace std;
int main()
{
  int t;
  cin>>t;
  for(int j=0;j<t;j++)
  {
      int n;
      cin>>n;
      int q[n];
      for(int i=0;i<n;i++)
        cin>>q[i];
      int p[n];
      p[0]=q[0];
      int test=1;
      string ch;
      for(int i=0;i<n;i++)
        ch=ch+'0';
      ch[p[0]-1]='1';
      int ind;
      for(int i=1;i<n;i++)
      {
          if (q[i]==q[i-1])
          {
                ind=ch.find('0');
                if ((ind>=0)and(ind+1<q[i]))
                {
                p[i]=ind+1;
                ch[ind]='1';
                }
                else
                {
                    cout<<-1<<endl;
                    test=0;
                    break;
                }
          }
          else
          {
               p[i]=q[i];
               ch[p[i]-1]='1';
          }
      }
      if (test==1)
      {
      for(int i=1;i<n;i++)
        if (ch[i]==0)
        {
            cout<<-1<<endl;
            test=0;
            break;
        }
     if(test==1)
     {
         for(int i=0;i<n;i++)
            cout<<p[i]<<" ";
         cout<<endl;
     }
      }
  }
}


#include <bits/stdc++.h>
#define N 1000000007;
using namespace std;
int main()
{
  int t;
  cin>>t;
  for(int j=0;j<t;j++)
  {
      int n;
      cin>>n;
      int q[n];
      for(int i=0;i<n;i++)
        cin>>q[i];
      int p[n];
      p[0]=q[0];
      int test=1;
      string ch;
      for(int i=0;i<n;i++)
        ch=ch+'0';
      ch[p[0]-1]='1';
      int ind;
      for(int i=1;i<n;i++)
      {
          if (q[i]==q[i-1])
          {
                ind=ch1.find(0);
                if (ind>=0)
                {
                p[i]=ind+1;
                ch[ind]='1';
                }
                else
                {
                    cout<<-1<<endl;
                    test=0;
                    break;
                }
          }
          else
          {
               p[i]=q[i];
               ch[p[i]-1]='1';
          }
      }
      if (test==1)
      {
      for(int i=1;i<n;i++)
        if (ch[i]==0)
        {
            cout<<-1<<endl;
            test=0;
            break;
        }
     if(test==1)
     {
         for(int i=0;i<n;i++)
            cout<<p[i]<<" ";
         cout<<endl;
     }
      }
  }
}


#include <bits/stdc++.h>
#define N 1000000007;
using namespace std;
int main()
{
  int t;
  cin>>t;
  for(int j=0;j<t;j++)
  {
      int n;
      cin>>n;
      int q[n];
      for(int i=0;i<n;i++)
        cin>>q[i];
      int p[n];
      p[0]=q[0];
      int test=1;
      string ch;
      for(int i=0;i<n;i++)
        ch=ch+'0';
      ch[p[0]-1]='1';
      int ind;
      for(int i=1;i<n;i++)
      {
          if (q[i]==q[i-1])
          {
                ind=ch.find(0);
                if (ind>=0)
                {
                p[i]=ind+1;
                ch[ind]='1';
                }
                else
                {
                    cout<<-1<<endl;
                    test=0;
                    break;
                }
          }
          else
          {
               p[i]=q[i];
               ch[p[i]-1]='1';
          }
      }
      if (test==1)
      {
      for(int i=1;i<n;i++)
        if (ch[i]==0)
        {
            cout<<-1<<endl;
            test=0;
            break;
        }
     if(test==1)
     {
         for(int i=0;i<n;i++)
            cout<<p[i]<<" ";
         cout<<endl;
     }
      }
  }
}


#include <bits/stdc++.h>
#define N 1000000007;
using namespace std;
int main()
{
  int t;
  cin>>t;
  for(int j=0;j<t;j++)
  {
      int n;
      cin>>n;
      int q[n];
      for(int i=0;i<n;i++)
        cin>>q[i];
      int p[n];
      p[0]=q[0];
      int test=1;
      string ch;
      for(int i=0;i<n;i++)
        ch=ch+'0';
      ch[p[0]-1]='1';
      int ind;
      for(int i=1;i<n;i++)
      {
          if (q[i]==q[i-1])
          {
                ind=ch.find('0');
                if (ind>=0)
                {
                p[i]=ind+1;
                ch[ind]='1';
                }
                else
                {
                    cout<<-1<<endl;
                    test=0;
                    break;
                }
          }
          else
          {
               p[i]=q[i];
               ch[p[i]-1]='1';
          }
      }
      if (test==1)
      {
      for(int i=1;i<n;i++)
        if (ch[i]==0)
        {
            cout<<-1<<endl;
            test=0;
            break;
        }
     if(test==1)
     {
         for(int i=0;i<n;i++)
            cout<<p[i]<<" ";
         cout<<endl;
     }
      }
  }
}


#include <bits/stdc++.h>
#define N 1000000007;
using namespace std;
int main()
{
  int t;
  cin>>t;
  for(int j=0;j<t;j++)
  {
      int n;
      cin>>n;
      int q[n];
      int done[n]={};
      int p[n]={};
      for(int i=0;i<n;i++)
        cin>>q[i];
      p[0]=q[0];
      done[p[0]-1]=1;
      for(int i=1;i<n;i++)
      {
          if (q[i]!=q[i-1])
                {
                    p[i]=q[i];
                    done[p[i]-1]=1;
                }

      }
      int cnt=1;
      for(int i=0;i<n;i++)
      {
          if (p[i]==0)
          {
             while ((cnt<q[i])and(done[cnt-1]==1))
                cnt++;
             if (done[cnt-1]==0)
             {
                 p[i]=cnt;
                 done[p[i]-1]=1;
             }
          }
      }
      int test=1;
      for(int i=0;i<n;i++)
      {
          if (done[i]==0)
          {
           cout<<-1<<endl;
           test=0;
           break;
          }
      }
      if(test==1)
      {
          for(int i=0;i<n;i++)
            cout<<p[i]<<" ";
          cout<<endl;
      }
  }
  return(0);
}


#include<bits/stdc++.h>
using namespace std;
int a[100005],vis[100005],p[100005],ans[100005];
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		int n;
		cin>>n;
		for(int i=1;i<=n;i++)vis[i]=ans[i]=0;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			if(!vis[a[i]])
			{
				ans[i]=a[i];
				vis[a[i]]=1;
			}
		}

		int t=0;
		for(int i=1;i<=n;i++)
		{
			if(!vis[i])p[++t]=i,vis[i]=1;
		}
		for(int i=1;i<=n;i++)
		{
			if(!ans[i])ans[i]=p[t--];
		}
		int x=0,flag=0;
		for(int i=1;i<=n;i++)
		{
			x=max(ans[i],a[i-1]);
			if(x!=a[i])
			{
				flag=1;
				break;
			}
		}
		for(int i=1;i<=n;i++)
		{
			if(ans[i]>n)
			{
				flag=1;
				break;
			}
		}
		if(flag)puts("-1");
		else
		{
			for(int i=1;i<=n;i++)cout<<ans[i]<<' ';
			cout<<'\n';
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
int a[100005],vis[100005],p[100005],ans[100005];
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		int n;
		cin>>n;
		for(int i=1;i<=n;i++)vis[i]=ans[i]=0;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			if(!vis[a[i]])
			{
				ans[i]=a[i];
				vis[a[i]]=1;
			}
		}
		int t=0;
		for(int i=1;i<=n;i++)
		{
			if(!vis[i])p[++t]=i;
		}
		for(int i=1;i<=n;i++)
		{
			if(!ans[i])ans[i]=p[t--];
		}
		int x=0,flag=0;
		for(int i=1;i<=n;i++)
		{
			x=max(ans[i],ans[i-1]);
			if(x!=a[i])
			{
				flag=1;
				break;
			}
		}
		if(flag)puts("-1");
		else
		{
			for(int i=1;i<=n;i++)cout<<ans[i]<<' ';
			cout<<'\n';
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
int a[100005],vis[100005],p[100005],ans[100005];
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		int n;
		cin>>n;
		for(int i=1;i<=n;i++)vis[i]=ans[i]=0;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			if(!vis[a[i]])
			{
				ans[i]=a[i];
				vis[a[i]]=1;
			}
		}

		int t=0;
		for(int i=1;i<=n;i++)
		{
			if(!vis[i])p[++t]=i;
		}
		for(int i=1;i<=n;i++)
		{
			if(!ans[i])ans[i]=p[t--];
		}
		int x=0,flag=0;
		for(int i=1;i<=n;i++)
		{
			x=max(ans[i],a[i-1]);
			if(x!=a[i])
			{
				flag=1;
				break;
			}
		}
		if(flag)puts("-1");
		else
		{
			for(int i=1;i<=n;i++)cout<<ans[i]<<' ';
			cout<<'\n';
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
int ans[100005],a[100005],vis[100005],p[100005];
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		int n;
		cin>>n;
		for(int i=1;i<=n;i++)vis[i]=ans[i]=0;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			if(!vis[a[i]])
			{
				ans[i]=a[i];
				vis[a[i]]=1;
			}
		}

//		for(int i=1;i<=n;i++)cout<<ans[i]<<' ';
//		cout<<'\n';

		int t=0;
		for(int i=1;i<=n;i++)
		{
			if(!vis[i])p[++t]=i;
		}

		int o=1;
		for(int i=1;i<=n;i++)
		{
			if(!ans[i])ans[i]=p[o++];
			if(o>t)break;
		}

		int x=0,flag=0;
		for(int i=1;i<=n;i++)
		{
			x=max(x,ans[i]);
			if(x!=a[i])
			{
				flag=1;
				break;
			}
		}
//		for(int i=1;i<=n;i++)cout<<ans[i]<<' ';
//		cout<<'\n';
		for(int i=1;i<=n;i++)
		{
			if(!ans[i]||ans[i]>n)
			{
				flag=1;
				break;
			}
		}

		if(flag)puts("-1");
		else
		{
			for(int i=1;i<=n;i++)cout<<ans[i]<<' ';
			cout<<'\n';
		}
	}
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define pb push_back

int main () {
    int t, n;
    scanf("%d", &t);
    while (t--) {
        const int N = 1e5 + 5;
        int flag[N] = {0}, q[N], p[N],cnt = 0;
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
            scanf("%d",  &q[i]);
        int minx = 1, s = 1, maxn = 1;
        for (int i = 0; i < n; i++) {
            if (!flag[q[i]]) {
                p[cnt++] = q[i];
                flag[q[i]] = 1,
                maxn = maxn < q[i] ? q[i] : maxn;
            }
            else {
                int temp = -1;
                for (int j = minx; j <= maxn; j++) {
                    if (!flag[j]) {
                        temp = j;
                        break;
                    }
                }
                if ((minx = temp) == -1) {
                    s = 0;
                    break;
                }
                p[cnt++] = minx, flag[minx]=1;
            }
        }
        if (!s) cout << -1 << endl;
        else {
          for (int i = 0; i < n; i++) printf("%d ", p[i]);
          puts("");
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define pb push_back

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t, n;
    cin >> t;
    while (t--) {
        const int N = 1e5 + 5;
        int flag[N] = {0};
        cin >> n;
        vector<int> q(n), p;
        for (int i = 0; i < n; i++)
            cin >> q[i];
        int minx = 1, s = 1, maxn = 1;
        for (int i = 0; i < n; i++) {
            if (!flag[q[i]]) {
                p.pb(q[i]),
                flag[q[i]] = 1,
                maxn = maxn > q[i] ? maxn : q[i];
            } else {
                int temp = -1;
                for (int j = minx; j <= maxn; j++) {
                    if (!flag[j]) {
                        temp = j;
                        break;
                    }
                }
                if ((minx = temp) == -1) {
                    s = 0;
                    break;
                }
                p.pb(minx), flag[minx] = 1;
            }
        }
        if (!s) cout << -1 << endl;
        else {
            for (auto i : p) {
                cout << i << " ";
            }
            cout << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define pb push_back

int main () {
    int t, n;
    scanf("%d", &t);
    while (t--) {
        const int N = 1e5 + 5;
        int flag[N] = {0}, q[N], p[N],cnt = 0;
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
            scanf("%d",  &q[i]);
        int minx = 1, s = 1, maxn = 1;
        for (int i = 0; i < n; i++) {
            if (!flag[q[i]]) {
                p[cnt++] = q[i];
                flag[q[i]] = 1,
                maxn = maxn < q[i] ? q[i] : maxn;
            }
            else {
                int temp = -1;
                for (int j = 1; j <= maxn; j++) {
                    if (!flag[j]) {
                        temp = j;
                        break;
                    }
                }
                if ((minx = temp) == -1) {
                    s = 0;
                    break;
                }
                p[cnt++] = minx, flag[minx]=1;
            }
        }
        if (!s) cout << -1 << endl;
        else {
          for (int i = 0; i < n; i++) printf("%d ", p[i]);
          puts("");
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define pb push_back

int main () {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t, n;
    cin >> t;
    while (t--) {
        const int N = 1e5 + 5;
        int flag[N] = {0};
        cin >> n;
        vector<int> q(n), p;
        for (int i = 0; i < n; i++)
            cin >> q[i];
        int minx = 1, s = 1, maxn = 1;
        for (int i = 0; i < n; i++) {
            if (q[i] > maxn) {
                maxn = q[i];
                p.pb(q[i]);
                flag[q[i]] = 1;
            }
            else if (!flag[q[i]]) {p.pb(q[i]), flag[q[i]] = 1;}
            else {
                int temp = -1;
                for (int j = 1; j <= maxn; j++) {
                    if (!flag[j]) {
                        temp = j;
                        break;
                    }
                }
                if ((minx = temp) == -1) {
                    s = 0;
                    break;
                }
                p.pb(minx), flag[minx]=1;
            }
        }
        if (!s) cout << -1 << endl;
        else {
            for (auto i : p) {
                cout << i << " ";
            }cout << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

bool check (int x, int y, int val) {
    if (val <= x && val <= y)
        return false;
    return true;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t, n;
    cin >> t;
    while (t--) {
        cin >> n;
        vector<int> q(n), p;
        for (int i = 0; i < n; i++) {
            cin >> q[i];
        }
        int minx = 1, maxn = -1;
        bool flag = true;
        for (int i = 0; i < n; i++) {
            if(!check(maxn, minx, q[i])) {
                flag = false;
                break;
            }
            else {
                if (q[i] > maxn) {
                    minx == (maxn = q[i]) ? ++minx : minx;
                    p.push_back(q[i]);
                } else {
                    if (q[i] <= maxn)
                        p.push_back(minx++);
                    else
                        p.push_back(q[i]);
                }
            }
        }
        if (!flag) cout << -1 << endl;
        else {
            for (auto i : p) cout << i << " ";
            cout << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define pb push_back

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t, n;
    cin >> t;
    while (t--) {
        const int N = 1e5 + 5;
        int flag[N] = {0};
        cin >> n;
        vector<int> q(n), p;
        for (int i = 0; i < n; i++)
            cin >> q[i];
        int minx = 1, s = 1, maxn = 1;
        for (int i = 0; i < n; i++) {
            if (!flag[q[i]]) {
                p.pb(q[i]),
                flag[q[i]] = 1,
                maxn = maxn > q[i] ? maxn : q[i];
            } else {
                int temp = -1;
                for (int j = 1; j <= maxn; j++) {
                    if (!flag[j]) {
                        temp = j;
                        break;
                    }
                }
                if ((minx = temp) == -1) {
                    s = 0;
                    break;
                }
                p.pb(minx), flag[minx] = 1;
            }
        }
        if (!s) cout << -1 << endl;
        else {
            for (auto i : p) {
                cout << i << " ";
            }
            cout << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include <custom/prettyprint.hpp>
#endif
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define sz(x) (int)x.size()
#define dbg(x) cerr << #x << " = " << x << '\n'

const int MOD = 1e9+7; //998244353;
const int inf = 1e9+3;
const ll INF = ll(3e18)+3;

void setIO(const string& s) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

void solve() {
    int n; cin >> n;
    vector<int> ans,arr(n+1);
    set<int> s;
    for(int i=1; i<=n; ++i) {
        cin >> arr[i];
        s.insert(i);
    }
    ans.emplace_back(arr[1]);
    s.erase(arr[1]);
    for(int i=2; i<=n; ++i) {
        // bigger element inserted
        if(arr[i] > arr[i-1]) {
            ans.emplace_back(arr[i]);
            s.erase(arr[i]);
        } else {
            // smaller element inserted
            auto it = s.lower_bound(arr[i]);
            if(it == s.begin()) {
                cout << "-1\n";
                return;
            }
            it = prev(it);
            ans.emplace_back(*it);
            s.erase(it);
        }
    }
    for(auto& i : ans)
        cout << i << ' ';
    cout << '\n';
}

signed main() {
    setIO("input");

    int t; cin >> t;
    while(t--)
        solve();

}


#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include <custom/prettyprint.hpp>
#endif
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define sz(x) (int)x.size()
#define dbg(x) cerr << #x << " = " << x << '\n'

const int MOD = 1e9+7; //998244353;
const int inf = 1e9+3;
const ll INF = ll(3e18)+3;

void setIO(const string& s) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

void solve() {
    int n; cin >> n;
    vector<int> ans,arr(n+1);
    set<int> s;
    for(int i=1; i<=n; ++i) {
        cin >> arr[i];
        s.insert(i);
    }
    ans.emplace_back(arr[1]);
    for(int i=2; i<=n; ++i) {
        // bigger element inserted
        if(arr[i] > arr[i-1]) {
            ans.emplace_back(arr[i]);
            s.erase(arr[i]);
        } else {
            // smaller element inserted
            auto it = s.upper_bound(arr[i]);
            if(it == s.begin()) {
                cout << "-1\n";
                return;
            }
            it = prev(it);
            ans.emplace_back(*it);
            s.erase(it);
        }
    }
    for(auto& i : ans)
        cout << i << ' ';
    cout << '\n';
}

signed main() {
    setIO("input");

    int t; cin >> t;
    while(t--)
        solve();

}


#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include <custom/prettyprint.hpp>
#endif
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define sz(x) (int)x.size()
#define dbg(x) cerr << #x << " = " << x << '\n'

const int MOD = 1e9+7; //998244353;
const int inf = 1e9+3;
const ll INF = ll(3e18)+3;

void setIO(const string& s) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

void solve() {
    int n; cin >> n;
    vector<int> ans,arr(n+1);
    set<int> s;
    for(int i=1; i<=n; ++i) {
        cin >> arr[i];
        s.insert(i);
    }
    ans.emplace_back(arr[1]);
    s.erase(arr[1]);
    for(int i=2; i<=n; ++i) {
        // bigger element inserted
        if(arr[i] > arr[i-1]) {
            ans.emplace_back(arr[i]);
            s.erase(arr[i]);
        } else {
            // smaller element inserted
            auto it = s.upper_bound(arr[i]);
            if(it == s.begin()) {
                cout << "-1\n";
                return;
            }
            it = prev(it);
            ans.emplace_back(*it);
            s.erase(it);
        }
    }
    for(auto& i : ans)
        cout << i << ' ';
    cout << '\n';
}

signed main() {
    setIO("input");

    int t; cin >> t;
    while(t--)
        solve();

}


#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include <custom/prettyprint.hpp>
#endif
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define sz(x) (int)x.size()
#define dbg(x) cerr << #x << " = " << x << '\n'

const int MOD = 1e9+7; //998244353;
const int inf = 1e9+3;
const ll INF = ll(3e18)+3;

void setIO(const string& s) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

void solve() {
    int n; cin >> n;
    vector<int> ans,arr(n+1);
    set<int> s;
    for(int i=1; i<=n; ++i) {
        cin >> arr[i];
        s.insert(i);
    }
    ans.emplace_back(arr[1]);
    for(int i=2; i<=n; ++i) {
        // bigger element inserted
        if(arr[i] > arr[i-1]) {
            ans.emplace_back(arr[i]);
            s.erase(arr[i]);
        } else {
            // smaller element inserted
            auto it = s.lower_bound(arr[i]);
            if(it == s.begin()) {
                cout << "-1\n";
                return;
            }
            it = prev(it);
            ans.emplace_back(*it);
            s.erase(it);
        }
    }
    for(auto& i : ans)
        cout << i << ' ';
    cout << '\n';
}

signed main() {
    setIO("input");

    int t; cin >> t;
    while(t--)
        solve();

}


#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include <custom/prettyprint.hpp>
#endif
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define sz(x) (int)x.size()
#define dbg(x) cerr << #x << " = " << x << '\n'

const int MOD = 1e9+7; //998244353;
const int inf = 1e9+3;
const ll INF = ll(3e18)+3;

void setIO(const string& s) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

void solve() {
    int n; cin >> n;
    vector<int> ans,arr(n+1);
    set<int> s;
    for(int i=1; i<=n; ++i) {
        cin >> arr[i];
        s.insert(i);
    }
    ans.emplace_back(arr[1]);
    for(int i=2; i<=n; ++i) {
        // bigger element inserted
        if(arr[i] > arr[i-1]) {
            ans.emplace_back(arr[i]);
            s.erase(arr[i]);
        } else {
            // smaller element inserted
            auto it = s.lower_bound(arr[i]);
            if(it == s.begin()) {
                cout << "-1\n";
                return;
            }
            advance(it, -1);
            ans.emplace_back(*it);
            s.erase(it);
        }
    }
    for(auto& i : ans)
        cout << i << ' ';
    cout << '\n';
}

signed main() {
    setIO("input");

    int t; cin >> t;
    while(t--)
        solve();

}


#include<bits/stdc++.h>

using namespace std;
typedef  long long   ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> a(n);
		queue<int> q;
		set<int> s;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			if (a[i] > i + 1)
				q.push(i + 1);
		}
		bool x = true;
		s.insert(a[0]);
		for (int i = n - 1; i > 0; --i) {
			if (a[i] == a[i - 1]) {
				if (q.empty())
					x = false;
				else {
					if (q.front() < a[i])
						a[i] = q.front(), q.pop();
					else
						x = false;
				}
			}
			s.insert(a[i]);
		}
		if (!x || s.size() != n) {
			cout << "-1\n";
			continue;
		}
		for (int i = 0; i < n; ++i)
			cout << a[i] << " ";
		cout << '\n';

	}

}


#include <bits/stdc++.h>
using namespace std;
typedef  long long   ll;
typedef  long double ld;
#define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	int t;
	cin >> t;
	while (t--) {
		int n, ok = 0;
		cin >> n;
		vector<int> mp(n + 1), a(n);
		for (auto& i : a)
			cin >> i, ++mp[i];
		for (int i = 0; i < n; ++i)
			ok |= a[i] == i;
		if (ok) {
			cout << "-1\n";
			continue;
		}
		for (int i = n - 1; i >= 0; --i)
			if (mp[a[i]] > 1) {
				--mp[a[i]];
				while (mp[a[i]])
					--a[i];
				++mp[a[i]];
			}
		for (auto i : a)
			cout << i << " ";
		cout << '\n';
	}

}


#include <algorithm>
#include<stdio.h>
#include <iostream>
#include<cmath>
#include <vector>
#include<string>
#include<stack>
#include<set>
#include <numeric>
#include<queue>
#include<map>

using namespace std;

typedef  long long   ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int t;

	cin >> t;

	while (t--) {
		bool p = true;
		int n;
		cin >> n;
		for (size_t i = 1; i <= n; i++)
		{
			int x;
			cin >> x;
			if (x < i) {
				p = false;

			}
		}
		if (p) {
			for (size_t i = 1; i <= n; i++)
			{
				cout << i << " ";
			}
			cout << '\n';
		}
		if (!p) {
			cout << -1 << '\n';
			p = true;
		}

	}

}


#include <bits/stdc++.h>
using namespace std;
typedef  long long   ll;
typedef  long double ld;
#define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	int t;
	cin >> t;
	while (t--) {
		int n, ok = 0;
		cin >> n;
		vector<int> mp(n + 1), a(n), ans(n);
		set<int> s;
		for (auto& i : a)
			cin >> i, ++mp[i];
		for (int i = 0; i < n; ++i)
			ok |= a[i] == i, s.insert(i + 1);
		if (ok) {
			cout << "-1\n";
			continue;
		}
		int mx = -1;
		for (int i = 0; i < n; ++i) {
			if (a[i] > mx)
				ans[i] = a[i], mx = a[i];
			if (s.find(a[i]) != s.end())
				s.erase(a[i]);
		}
		for(int i = 0; i <n; ++i)
			if (!ans[i])
				ans[i] = *s.begin(), s.erase(*s.begin());
		for (auto i : ans)
			cout << i << " ";
		cout << '\n';
	}

}


#include <bits/stdc++.h>
using namespace std;
typedef  long long   ll;
typedef  long double ld;
#define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	int t;
	cin >> t;
	while (t--) {
		int n, ok = 0;
		cin >> n;
		vector<int> mp(n + 1), a(n), ans(n);
		for (auto& i : a)
			cin >> i, ++mp[i];
		for (int i = 0; i < n; ++i)
			ok |= a[i] == i;
		if (ok) {
			cout << "-1\n";
			continue;
		}
		int mx = -1;
		for (int i = 0, j = 1; i < n; ++i) {
			if (a[i] > mx)
				ans[i] = a[i], mx = a[i];
			else {
				while (mp[j])
					++j;
				++mp[j], ans[i] = j;
			}
		}
		for (auto i : ans)
			cout << i << " ";
		cout << '\n';
	}

}


#include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int t,n;
	cin >> t;
	while(t--) {
		int val = -1;
		bool impossible = false;
		cin >> n;
		int ans[n+1];
		int vis[n+1];
		int q[n+1];
		for(int i=0;i<n;i++) {
			ans[i] = 0;
			vis[i+1] = 0;
			cin >> q[i];
		}
		ans[0] = q[0];
		vis[q[0]] = 1;
		for(int i=1;i<n;i++) {
			if(q[i]>q[i-1]) {
				ans[i] = q[i];
				vis[q[i]] = 1;
			} else if(q[i] == q[i-1]) {
				for(int j=1;j<=q[i];j++) {
					if(vis[j] == 0) {
						ans[i] = j;
						vis[j] = 1;
						break;
					}
				}
			} else {
				impossible = true;
				break;
			}
		}
		if(impossible) {
			cout << val << endl;
		} else {
			for(int i=0;i<n-1;i++) {
				cout << ans[i] << " ";
			}
			cout << ans[n-1];
			cout << endl;
		}
	}
}


#include<iostream>
using namespace std;
int main() {
	int t,n;
	cin >> t;
	while(t--) {
		bool impossible = false;
		cin >> n;
		int ans[n+1];
		int vis[n+1];
		int q[n+1];
		for(int i=0;i<n;i++) {
			ans[i] = 0;
			vis[i+1] = 0;
			cin >> q[i];
		}
		ans[0] = q[0];
		vis[q[0]] = 1;
		for(int i=1;i<n;i++) {
			if(q[i]>ans[i-1]) {
				ans[i] = q[i];
				vis[q[i]] = 1;
			} else if(q[i] == ans[i-1] && i==n-1) {
				for(int j=1;j<=n;j++) {
					if(vis[j] == 0){
						ans[i] = j;
						break;
					}
				}
			} else {
				impossible = true;
				break;
			}
		}
		if(impossible) {
			cout << "-1" << endl;
		} else {
			for(int i=0;i<n;i++) {
				cout << ans[i] << " ";
			}
			cout << endl;
		}
	}
}


#include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int t,n;
	cin >> t;
	while(t--) {
		int val = -1;
		bool impossible = false;
		cin >> n;
		int ans[n+1];
		int vis[n+1];
		int q[n+1];
		for(int i=0;i<n;i++) {
			ans[i] = 0;
			vis[i+1] = 0;
			cin >> q[i];
		}
		ans[0] = q[0];
		vis[q[0]] = 1;
		for(int i=1;i<n;i++) {
			if(q[i]>q[i-1]) {
				ans[i] = q[i];
				vis[q[i]] = 1;
			} else if(q[i] == q[i-1]) {
				for(int j=1;j<=n;j++) {
					if(vis[j] == 0) {
						ans[i] = j;
						vis[j] = 1;
						break;
					}
				}
			} else {
				impossible = true;
				break;
			}
		}
		for(int i=1;i<=n;i++){
			vis[i] = 0;
		}
		for(int i=0;i<n;i++) {
			vis[ans[i]] = 1;
		}
		for(int i=1;i<=n;i++) {
			if(vis[i]==0) {
				impossible = true;
				break;
			}
		}
		if(impossible) {
			cout << val << endl;
		} else {
			for(int i=0;i<n-1;i++) {
				cout << ans[i] << " ";
			}
			cout << ans[n-1];
			cout << endl;
		}
	}
}


#include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int t,n;
	cin >> t;
	while(t--) {
		int val = -1;
		bool impossible = false;
		cin >> n;
		int ans[n+1];
		int vis[n+1];
		int q[n+1];
		for(int i=0;i<n;i++) {
			ans[i] = 0;
			vis[i+1] = 0;
			cin >> q[i];
		}
		ans[0] = q[0];
		vis[q[0]] = 1;
		for(int i=1;i<n;i++) {
			if(q[i]>q[i-1]) {
				ans[i] = q[i];
				vis[q[i]] = 1;
			} else if(q[i] == q[i-1]) {
				for(int j=1;j<=q[i];j++) {
					if(vis[j] == 0) {
						ans[i] = j;
						vis[j] = 1;
						break;
					}
				}
			} else {
				impossible = true;
				break;
			}
		}
		for(int i=1;i<=n;i++){
			vis[i] = 0;
		}
		for(int i=0;i<n;i++) {
			vis[ans[i]] = 1;
		}
		for(int i=1;i<=n;i++) {
			if(vis[i]==0) {
				impossible = true;
				break;
			}
		}
		if(impossible) {
			cout << val << endl;
		} else {
			for(int i=0;i<n-1;i++) {
				cout << ans[i] << " ";
			}
			cout << ans[n-1];
			cout << endl;
		}
	}
}


#include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int t,n;
	cin >> t;
	while(t--) {
		int val = -1;
		bool impossible = false;
		cin >> n;
		int ans[n+1];
		int vis[n+1];
		int q[n+1];
		int lastVisit = 1;
		for(int i=0;i<n;i++) {
			ans[i] = 0;
			vis[i+1] = 0;
			cin >> q[i];
		}
		ans[0] = q[0];
		vis[q[0]] = 1;
		for(int i=1;i<n;i++) {
			if(q[i]>q[i-1]) {
				ans[i] = q[i];
				vis[q[i]] = 1;
			} else if(q[i] == q[i-1]) {
				bool found = false;
				for(int j=lastVisit;j<=q[i];j++) {
					if(vis[j] == 0) {
						ans[i] = j;
						vis[j] = 1;
						lastVisit = j;
						found = true;
						break;
					}
				}
				if(!found) {
					impossible = true;
					break;
				}
			} else {
				impossible = true;
				break;
			}
		}
		if(impossible) {
			cout << val << endl;
		} else {
			for(int i=0;i<n-1;i++) {
				cout << ans[i] << " ";
			}
			cout << ans[n-1];
			cout << endl;
		}
	}
}


#include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int t,n;
	cin >> t;
	while(t--) {
		int val = -1;
		bool impossible = false;
		cin >> n;
		int ans[n+1];
		int vis[n+1];
		int q[n+1];
		for(int i=0;i<n;i++) {
			ans[i] = 0;
			vis[i+1] = 0;
			cin >> q[i];
		}
		ans[0] = q[0];
		vis[q[0]] = 1;
		for(int i=1;i<n;i++) {
			if(q[i]>q[i-1]) {
				ans[i] = q[i];
				vis[q[i]] = 1;
			} else if(q[i] == q[i-1] && i==n-1) {
				for(int j=1;j<=n;j++) {
					if(vis[j] == 0) {
						ans[i] = j;
						vis[j] = 1;
						break;
					}
				}
			} else {
				impossible = true;
				break;
			}
		}
		for(int i=1;i<=n;i++){
			vis[i] = 0;
		}
		for(int i=0;i<n;i++) {
			vis[ans[i]] = 1;
		}
		for(int i=1;i<=n;i++) {
			if(vis[i]==0) {
				impossible = true;
				break;
			}
		}
		if(impossible) {
			cout << val << endl;
		} else {
			for(int i=0;i<n-1;i++) {
				cout << ans[i] << " ";
			}
			cout << ans[n-1];
			cout << endl;
		}
	}
}


#include<iostream>
using namespace std;
int main() {
	int t,n;
	cin >> t;
	while(t--) {
		bool impossible = false;
		cin >> n;
		int ans[n+1];
		int vis[n+1];
		int q[n+1];
		for(int i=0;i<n;i++) {
			ans[i] = 0;
			vis[i+1] = 0;
			cin >> q[i];
		}
		ans[0] = q[0];
		vis[q[0]] = 1;
		for(int i=1;i<n;i++) {
			if(q[i]>ans[i-1]) {
				ans[i] = q[i];
				vis[q[i]] = 1;
			} else if(q[i] == q[i-1]) {
				int cnt = 0;
				for(int j=1;j<=n;j++) {
					if(vis[j] == 0) {
						ans[i] = j;
						cnt++;
					}
				}
				if(cnt>1) {
					impossible = true;
					break;
				}
			} else {
				impossible = true;
				break;
			}
		}
		if(impossible) {
			cout << "-1" << endl;
		} else {
			for(int i=0;i<n-1;i++) {
				cout << ans[i] << " ";
			}
			cout << ans[n-1];
			cout << endl;
		}
	}
}


#include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int t,n;
	cin >> t;
	while(t--) {
		int val = -1;
		bool impossible = false;
		cin >> n;
		int ans[n+1];
		int vis[n+1];
		int q[n+1];
		for(int i=0;i<n;i++) {
			ans[i] = 0;
			vis[i+1] = 0;
			cin >> q[i];
		}
		ans[0] = q[0];
		vis[q[0]] = 1;
		for(int i=1;i<n;i++) {
			if(q[i]>q[i-1]) {
				ans[i] = q[i];
				vis[q[i]] = 1;
			} else if(q[i] == q[i-1]) {
				for(int j=1;j<=q[i]+1;j++) {
					if(vis[j] == 0) {
						ans[i] = j;
						vis[j] = 1;
						break;
					}
				}
			} else {
				impossible = true;
				break;
			}
		}
		if(impossible) {
			cout << val << endl;
		} else {
			for(int i=0;i<n-1;i++) {
				cout << ans[i] << " ";
			}
			cout << ans[n-1];
			cout << endl;
		}
	}
}


#include<iostream>
using namespace std;
int main() {
	int t,n;
	cin >> t;
	while(t--) {
		int val = -1;
		bool impossible = false;
		cin >> n;
		int ans[n+1];
		int vis[n+1];
		int q[n+1];
		for(int i=0;i<n;i++) {
			ans[i] = 0;
			vis[i+1] = 0;
			cin >> q[i];
		}
		ans[0] = q[0];
		vis[q[0]] = 1;
		for(int i=1;i<n;i++) {
			if(q[i]>q[i-1]) {
				ans[i] = q[i];
				vis[q[i]] = 1;
			} else if(q[i] == q[i-1] && i==n-1) {
				for(int j=1;j<=n;j++) {
					if(vis[j] == 0) {
						ans[i] = j;
						vis[j] = 1;
						break;
					}
				}
			} else {
				impossible = true;
				break;
			}
		}
		for(int i=1;i<=n;i++){
			vis[i] = 0;
		}
		for(int i=0;i<n;i++) {
			vis[ans[i]] = 1;
		}
		for(int i=1;i<=n;i++) {
			if(vis[i]==0) {
				impossible = true;
				break;
			}
		}
		if(impossible) {
			cout << val << endl;
		} else {
			for(int i=0;i<n-1;i++) {
				cout << ans[i] << " ";
			}
			cout << ans[n-1];
			cout << endl;
		}
	}
}