#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
const int mod = 1000000007;
typedef long long ll;
const int maxn = 100000+5;
ll a[maxn];
ll power(ll a,ll k){
    ll r=1;
    a%=mod;
    while(k){
        if(k&1) r=r*a%mod;
        a=a*a%mod;
        k>>=1;
    }
    return r;
}
int main()
{
    ll n,x;
    scanf("%I64d%I64d",&n,&x);
    ll sum=0;
    for(int i=1;i<=n;i++) scanf("%I64d",&a[i]),sum+=a[i];
    for(int i=1;i<=n;i++) a[i]=sum-a[i];
    ll pnt=a[1];
    for(int i=1;i<=n;i++) pnt=min(pnt,a[i]);
    for(int i=1;i<=n;i++) a[i]-=pnt;
    //pnt%=(mod-1);
    priority_queue<ll,vector<ll>,greater<ll> >Que;
    for(int i=1;i<=n;i++) Que.push(a[i]);
    while(1)
    {
        ll mn=Que.top(),cnt=0;
        Que.pop();cnt++;
        if(Que.empty()){
            while(mn%x==0) pnt++,mn/=x;
          //  pnt%=(mod-1);
            printf("%I64d\n",power(x,pnt));
            return 0;
        }
        while(!Que.empty()&&Que.top()==mn) Que.pop(),cnt++;
        if(cnt%x!=0) {
           // pnt%=(mod-1);
            printf("%I64d\n",power(x,pnt));
            return 0;
        }
        else {
            for(int i=0;i<cnt/x;i++)
                Que.push(mn+1);
            pnt++;
        }
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
const int mod = 1000000007;
typedef long long ll;
const int maxn = 100000+5;
ll a[maxn];
ll power(ll a,ll k){
    ll r=1;
    a%=mod;
    while(k){
        if(k&1) r=r*a%mod;
        a=a*a%mod;
        k>>=1;
    }
    return r;
}
int main()
{
    ll n,x;
    scanf("%I64d%I64d",&n,&x);
    ll sum=0;
    for(int i=1;i<=n;i++) scanf("%I64d",&a[i]),sum+=a[i];
    for(int i=1;i<=n;i++) a[i]=sum-a[i];
    ll pnt=a[1];
    for(int i=1;i<=n;i++) pnt=min(pnt,a[i]);
    for(int i=1;i<=n;i++) a[i]-=pnt;
    pnt%=(mod-1);
    priority_queue<ll,vector<ll>,less<ll> >Que;
    for(int i=1;i<=n;i++) Que.push(a[i]);
    while(1)
    {
        ll mn=Que.top(),cnt=0;
        Que.pop();cnt++;
        if(Que.empty()){
            while(mn%x==0) pnt++,mn/=x;
            pnt%=(mod-1);
            printf("%I64d\n",power(x,pnt));
            return 0;
        }
        while(!Que.empty()&&Que.top()==mn) Que.pop(),cnt++;
        if(cnt%x!=0) {
            pnt%=(mod-1);
            printf("%I64d\n",power(x,pnt));
            return 0;
        }
        else {
            for(int i=0;i<cnt/x;i++)
                Que.push(mn+1);
            pnt++;
        }
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
const int mod = 1000000007;
typedef long long ll;
const int maxn = 100000+5;
ll a[maxn];
ll power(ll a,ll k){
    ll r=1;
    a%=mod;
    while(k){
        if(k&1) r=r*a%mod;
        a=a*a%mod;
        k>>=1;
    }
    return r;
}
int main()
{
    ll n,x;
    scanf("%I64d%I64d",&n,&x);
    ll sum=0;
    for(int i=1;i<=n;i++) scanf("%I64d",&a[i]),sum+=a[i];
    for(int i=1;i<=n;i++) a[i]=sum-a[i];
    ll mnn=a[1];
    for(int i=1;i<=n;i++) mnn=min(mnn,a[i]);
    ll pnt=mnn;
    for(int i=1;i<=n;i++) a[i]=a[i]-mnn;
    priority_queue<ll>Que;
    for(int i=1;i<=n;i++)
        Que.push(a[i]);
    while(1)
    {
        ll mn=Que.top(),cnt=0;
        Que.pop(),cnt++;
        while(Que.top()==mn&&!Que.empty()) Que.pop(),cnt++;
        if(cnt%x!=0) {
            pnt%=(mod-1);
            printf("%d\n",power(x,pnt));
            return 0;
        }
        else {
            for(int i=0;i<cnt/x;i++)
                Que.push(mn+1);
            pnt++;
        }
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
const int mod = 1000000007;
typedef long long ll;
const int maxn = 100000+5;
ll a[maxn];
ll power(ll a,ll k){
    ll r=1;
    a%=mod;
    while(k){
        if(k&1) r=r*a%mod;
        a=a*a%mod;
        k>>=1;
    }
    return r;
}
int main()
{
    ll n,x;
    scanf("%I64d%I64d",&n,&x);
    ll sum=0;
    for(int i=1;i<=n;i++) scanf("%I64d",&a[i]),sum+=a[i];
    for(int i=1;i<=n;i++) a[i]=sum-a[i];
    ll pnt=a[1];
    for(int i=1;i<=n;i++) pnt=min(pnt,a[i]);
    for(int i=1;i<=n;i++) a[i]-=pnt;
    pnt%=(mod-1);
    priority_queue<ll,vector<ll>,greater<ll> >Que;
    for(int i=1;i<=n;i++) Que.push(a[i]);
    while(1)
    {
        ll mn=Que.top(),cnt=0;
        Que.pop();cnt++;
        if(Que.empty()){
            while(mn%x==0) pnt++,mn/=x;
           pnt%=(mod-1);
            printf("%I64d\n",power(x,pnt));
            return 0;
        }
        while(!Que.empty()&&Que.top()==mn) Que.pop(),cnt++;
        if(cnt%x!=0) {
            pnt%=(mod-1);
            printf("%I64d\n",power(x,pnt));
            return 0;
        }
        else {
            queue<ll>QQ;
            while(!Que.empty())
            {
                ll num=Que.top()-1;
                QQ.push(num);
                Que.pop();
            }
            while(!QQ.empty())
            {
                ll num=QQ.front();
                Que.push(num);
                QQ.pop();
            }
            for(int i=0;i<cnt/x;i++)
                Que.push(mn+1);
            pnt++;
        }
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
const int mod = 1000000007;
typedef long long ll;
const int maxn = 100000+5;
ll a[maxn];
ll power(ll a,ll k){
    ll r=1;
    a%=mod;
    while(k){
        if(k&1) r=r*a%mod;
        a=a*a%mod;
        k>>=1;
    }
    return r;
}
int main()
{
    ll n,x;
    scanf("%I64d%I64d",&n,&x);
    ll sum=0;
    for(int i=1;i<=n;i++) scanf("%I64d",&a[i]),sum+=a[i];
    for(int i=1;i<=n;i++) a[i]=sum-a[i];
    ll mnn=a[1];
    for(int i=1;i<=n;i++) mnn=min(mnn,a[i]);
    ll pnt=mnn;
    for(int i=1;i<=n;i++) a[i]-=mnn;
    priority_queue<ll>Que;
    for(int i=1;i<=n;i++)
        Que.push(a[i]);
    while(1)
    {
        ll mn=Que.top(),cnt=0;
        Que.pop(),cnt++;
        if(Que.empty())
        {
            if(mn%x==0) pnt++;
            pnt%=(mod-1);
            printf("%I64d\n",power(x,pnt));
            return 0;
        }
        while(!Que.empty()&&Que.top()==mn) Que.pop(),cnt++;
        if(cnt%x!=0) {
            pnt%=(mod-1);
            printf("%I64d\n",power(x,pnt));
            return 0;
        }
        else {
            for(int i=0;i<cnt/x;i++)
                Que.push(mn+1);
            pnt++;
        }
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
const int mod = 1000000007;
typedef long long ll;
const int maxn = 100000+5;
ll a[maxn];
ll power(ll a,ll k){
    ll r=1;
    a%=mod;
    while(k){
        if(k&1) r=r*a%mod;
        a=a*a%mod;
        k>>=1;
    }
    return r;
}
int main()
{
    ll n,x;
    scanf("%I64d%I64d",&n,&x);
    ll sum=0;
    for(int i=1;i<=n;i++) scanf("%I64d",&a[i]),sum+=a[i];
    for(int i=1;i<=n;i++) a[i]=sum-a[i];
    ll pnt=a[1];
    for(int i=1;i<=n;i++) pnt=min(pnt,a[i]);
    for(int i=1;i<=n;i++) a[i]-=pnt;
    priority_queue<ll>Que;
    for(int i=1;i<=n;i++) Que.push(a[i]);
    while(1)
    {
        ll mn=Que.top(),cnt=0;
        Que.pop();cnt++;
        if(Que.empty()){
            while(mn%x==0) pnt++,mn/=x;
            pnt%=(mod-1);
            printf("%I64d\n",power(x,pnt));
            return 0;
        }
        while(!Que.empty()&&Que.top()==mn) Que.pop(),cnt++;
        if(cnt%x!=0) {
            pnt%=(mod-1);
            printf("%I64d\n",power(x,pnt));
            return 0;
        }
        else {
            for(int i=0;i<cnt/x;i++)
                Que.push(mn+1);
            pnt++;
        }
    }
    return 0;
}


#include<cstdio>
#include<map>
using namespace std;
#define MOD 1000000007
#define LL __int64
int n, i;
LL a[100000], x, s, t, r;
map<LL,LL> MP;
map<LL,LL>::iterator it;
void solve(){
    LL ans=1;
    while(s>0){
        if(s%2==1)  ans = (ans*x)%MOD;
        x = (x*x)%MOD;
        s/=2;
    }
    printf("%I64d\n", ans);
}
int main(){
    while(~scanf("%d %I64d", &n, &x)){
        MP.clear();
        s=0;
        for(i=0; i<n; i++){
            scanf("%I64d", &a[i]);
            s+=a[i];
        }
        for(i=0; i<n; i++){
            MP[s-a[i]]++;
        }
        while(1){
            it = MP.begin();
            t = it->first;
            r = it->second;
            MP.erase(t);
            if(r%x>0){
                if(t<s) s=t;
                solve();
                break;
            }
            r/=x;
            t++;
            MP[t]+=r;
        }
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
unsigned int exp_mod(int a,int n,int c)
{
    if(n==0) return 1%c;
    unsigned int t=exp_mod((a*a)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
int main()
{
    int i,sum,max,n,ns=0;
    long x,v[N];
    scanf("%d%ld%d",&n,&x,&max);
    sum=v[0]=max;
    for(i=1;i<n;i++){scanf("%ld",&v[i]);
    sum+=v[i];
    if (v[i]>max)
        max=v[i];
    }
    for(i=0;i<n;i++){
     if(max==v[i])ns++;
    }
    sum-=max;
    printf("%ld\n",!(ns%x)?exp_mod(x,sum+ns/x,GCD):exp_mod(x,sum,GCD));
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
void solve(long long x,long long s){
    long long ans=1;
    while(s>0){
        if(s%2==1)  ans = (ans*x)%GCD;
        x = (x*x)%GCD;
        s/=2;
    }
    printf("%I64d\n", ans);
}
long long findmax(long long v[],long long n,long long x)
{   if(x==1)return 0;
else{
    int i,ns=0,cnt;
    long long max=v[0];
    for(i=1;i<n;i++)if(max<v[i])max=v[i];
    for(i=0;i<n;i++)if(max==v[i])ns++;
    if(!(ns%x)){
         cnt=ns/x;
    for(i=0;i<n;i++)
    {
        if(v[i]==max){
            if(cnt)v[i]--,cnt--;
            else v[i]=0;
    }
    }

        return findmax(v,n,x);
    }
    return max;
    }
}
int main()
{
    int i;
    long long sum=0,n,x,v[N];
    scanf("%I64d%I64d",&n,&x);
    for(i=0;i<n;i++){scanf("%I64d",&v[i]);sum+=v[i];}
    n=findmax(v, n, x);
    if(n>0)sum-=n;
    solve(x,sum);
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
unsigned long exp_mod(unsigned long a,int n,int c)
{
    if(n==0) return 1%c;
    unsigned long t=exp_mod((a*a)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
int main()
{
    int i,n,ns=0;
    unsigned long sum,max;
    long x,v[N];
    scanf("%d%ld%ld",&n,&x,&max);
    sum=v[0]=max;
    for(i=1;i<n;i++){scanf("%ld",&v[i]);
    sum+=v[i];
    if (v[i]>max)
        max=v[i];
    }
    for(i=0;i<n;i++){
     if(max==v[i])ns++;
    }
    sum-=max;
    printf("%ld\n",!(ns%x)?exp_mod(x,sum+ns/x,GCD):exp_mod(x,sum,GCD));
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
long long exp_mod(long long a,long n,int c)
{
    if(n==0) return 1%c;
    long long t=exp_mod((a%c*a%c)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
long long findmax(long long v[],long long n,long long x)
{   if(x==1)return 0;
else{
    int i,ns=0,cnt;
    long long max=v[0];
    for(i=1;i<n;i++)if(max<v[i])max=v[i];
    for(i=0;i<n;i++)if(max==v[i])ns++;
    if(!(ns%x)){
         cnt=ns/x;
    for(i=0;i<n;i++)
    {
        if(v[i]==max){
            if(cnt)v[i]--,cnt--;
            else v[i]=0;
    }
    }

        return findmax(v,n,x);
    }
    return max;
    }
}
int main()
{
    int i;
    long long sum=0,n,x,v[N];
    scanf("%I64d%I64d",&n,&x);
    for(i=0;i<n;i++){scanf("%I64d",&v[i]);sum+=v[i];}
    n=findmax(v, n, x);
    sum-=n;
    printf("%I64d\n",x==1?1:exp_mod(x,sum,GCD));
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100
unsigned int exp_mod(int a,int n,int c)
{
    if(n==0) return 1%c;
    unsigned int t=exp_mod((a*a)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
int main()
{
    int i,sum,max,n,x,v[N],ns=0;
    scanf("%d%d%d",&n,&x,&max);
    sum=v[0]=max;
    for(i=1;i<n;i++){scanf("%d",&v[i]);
    sum+=v[i];
    if (v[i]>max)
        max=v[i];
    }
    for(i=0;i<n;i++){
     if(max==v[i])ns++;
    }
    sum-=max;
    printf("%ld\n",!(ns%x)?exp_mod(x,sum+ns/x,GCD):exp_mod(x,sum,GCD));
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
unsigned long exp_mod(unsigned long a,int n,int c)
{
    if(n==0) return 1%c;
    unsigned long t=exp_mod((a*a)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
unsigned long findmax(unsigned v[],int n,unsigned long x,unsigned blocks)
{   if(x==1)return;
else{
    int i,ns=0;
    unsigned long max=v[0];
    for(i=1;i<n;i++)if(max<v[i]&&v[i]!=blocks)max=v[i];
    for(i=0;i<n;i++)if(max==v[i])ns++;
    if(!(ns%x)){for(i=0;i<n;i++)if(v[i]==max){
            v[i]-=ns/x;
            blocks=max;
    break;
    }
    return findmax(v,n,x,blocks);
    }
    return max;
}
}

int main()
{
    int i,n;
    unsigned long sum=0;
    long x,v[N];
    scanf("%d%u",&n,&x);
    for(i=0;i<n;i++){scanf("%u",&v[i]);sum+=v[i];}
    sum-=findmax(v,n,x,-1);
    printf("%ld\n",x==1?1:exp_mod(x,sum,GCD));
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
long long exp_mod(long long a,long n,int c)
{
    if(n==0) return 1%c;
    long long t=exp_mod((a%c*a%c)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
long long findmax(long long v[],long long n,long long x)
{   if(x==1)return 0;
else{
    int i,ns=0,flag=0;
    long long max=v[0];
    for(i=1;i<n;i++)if(max<v[i])max=v[i];
    for(i=0;i<n;i++)if(max==v[i])ns++;
    if(!(ns%x)){
        for(i=0;i<n;i++)
        if(v[i]==max)
            {
        (!flag)?(v[i]-=(ns/x),flag=1):(v[i]=0);
            }

        return findmax(v,n,x);
    }
    return max;
}
}

int main()
{
    int i;
    long long sum=0,n,x,v[N];
    scanf("%I64d%I64d",&n,&x);
    for(i=0;i<n;i++){scanf("%I64d",&v[i]);sum+=v[i];}
    n=findmax(v, n, x);
    if (n>0) {
        sum-=n;
    }
    printf("%I64d\n",x==1?1:exp_mod(x,sum,GCD));
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
unsigned long exp_mod(unsigned long a,int n,int c)
{
    if(n==0) return 1%c;
    unsigned long t=exp_mod((a*a)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
unsigned long findmax(long v[],int n,unsigned long x)
{   if(x==1)return 0;
else{
    int i,ns=0,flag=0;
    unsigned long max=v[0];
    for(i=1;i<n;i++)if(max<v[i])max=v[i];
    for(i=0;i<n;i++)if(max==v[i])ns++;
    if(!(ns%x)){
        for(i=0;i<n;i++)
        if(v[i]==max)
            {
        (!flag)?(v[i]-=(ns/x),flag=1):(v[i]=0);
            }

        return findmax(v,n,x);
    }
    return max;
}
}

int main()
{
    int i,n;
    unsigned long sum=0;
    long x,v[N];
    scanf("%d%ld",&n,&x);
    for(i=0;i<n;i++){scanf("%ld",&v[i]);sum+=v[i];}
    sum-=findmax(v,n,x);
    printf("%ld\n%d",x==1?1:exp_mod(x,sum,GCD),sum);
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
unsigned long exp_mod(unsigned long a,int n,int c)
{
    if(n==0) return 1%c;
    unsigned long t=exp_mod((a*a)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
unsigned long findmax(long v[],int n,unsigned long x,unsigned long blocks)
{   if(x==1)return 0;
else{
    int i,ns=0;
    unsigned long max=v[0];
    for(i=1;i<n;i++)if(max<v[i]&&v[i]!=blocks)max=v[i];
    for(i=0;i<n;i++)if(max==v[i])ns++;
    if(!(ns%x)){for(i=0;i<n;i++)if(v[i]==max){
        v[i]-=ns/x;
        blocks=max;
        break;
    }
        return findmax(v,n,x,blocks);
    }
    return max;
}
}

int main()
{
    int i,n;
    unsigned long sum=0;
    long x,v[N];
    scanf("%d%ld",&n,&x);
    for(i=0;i<n;i++){scanf("%ld",&v[i]);sum+=v[i];}
    sum-=findmax(v,n,x,-1);
    printf("%ld\n",x==1?1:exp_mod(x,sum,GCD));
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
long long exp_mod(long long a,int n,int c)
{
    if(n==0) return 1%c;
    long long t=exp_mod((a%c*a%c)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
long long findmax(long v[],int n,long long x)
{   if(x==1)return 0;
else{
    int i,ns=0,flag=0;
    long long max=v[0];
    for(i=1;i<n;i++)if(max<v[i])max=v[i];
    for(i=0;i<n;i++)if(max==v[i])ns++;
    if(!(ns%x)){
        for(i=0;i<n;i++)
        if(v[i]==max)
            {
        (!flag)?(v[i]-=(ns/x),flag=1):(v[i]=0);
            }

        return findmax(v,n,x);
    }
    return max;
}
}

int main()
{
    int i,n;
    long long sum=0;
    long x,v[N];
    scanf("%d%ld",&n,&x);
    for(i=0;i<n;i++){scanf("%ld",&v[i]);sum+=v[i];}
    sum-=findmax(v,n,x);
    printf("%ld\n%d",x==1?1:exp_mod(x,sum,GCD),sum);
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
long long exp_mod(long long a,int n,int c)
{
    if(n==0) return 1%c;
    long long t=exp_mod((a%c*a%c)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
long long findmax(long v[],int n,long long x)
{   if(x==1)return 0;
else{
    int i,ns=0,flag=0;
    long long max=v[0];
    for(i=1;i<n;i++)if(max<v[i])max=v[i];
    for(i=0;i<n;i++)if(max==v[i])ns++;
    if(!(ns%x)){
        for(i=0;i<n;i++)
        if(v[i]==max)
            {
        (!flag)?(v[i]-=(ns/x),flag=1):(v[i]=0);
            }

        return findmax(v,n,x);
    }
    return max;
}
}

int main()
{
    int i,n;
    long long sum=0;
    long x,v[N];
    scanf("%d%ld",&n,&x);
    for(i=0;i<n;i++){scanf("%ld",&v[i]);sum+=v[i];}
    sum-=findmax(v,n,x);
    printf("%ld\n",x==1?1:exp_mod(x,sum,GCD));
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
void solve(long x,long s){
    long long ans=1;
    while(s>0){
        if(s%2==1)  ans = (ans*x)%GCD;
        x = (x*x)%GCD;
        s/=2;
    }
    printf("%I64d\n", ans);
}
long long findmax(long long v[],long long n,long long x)
{   if(x==1)return 0;
else{
    int i,ns=0,cnt;
    long long max=v[0];
    for(i=1;i<n;i++)if(max<v[i])max=v[i];
    for(i=0;i<n;i++)if(max==v[i])ns++;
    if(!(ns%x)){
         cnt=ns/x;
    for(i=0;i<n;i++)
    {
        if(v[i]==max){
            if(cnt)v[i]--,cnt--;
            else v[i]=0;
    }
    }

        return findmax(v,n,x);
    }
    return max;
    }
}
int main()
{
    int i;
    long long sum=0,n,x,v[N];
    scanf("%I64d%I64d",&n,&x);
    for(i=0;i<n;i++){scanf("%I64d",&v[i]);sum+=v[i];}
    n=findmax(v, n, x);
    if(n>0)sum-=n;
    solve(x,sum);
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
unsigned long exp_mod(unsigned long a,int n,int c)
{
    if(n==0) return 1%c;
    unsigned long t=exp_mod((a*a)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
unsigned long findmax(unsigned v[],int n,unsigned long x,unsigned blocks)
{   if(x==1)return;
else{
    int i,ns=0;
    unsigned long max=v[0];
    for(i=1;i<n;i++)if(max<v[i]&&v[i]!=blocks)max=v[i];
    for(i=0;i<n;i++)if(max==v[i])ns++;
    if(!(ns%x)){for(i=0;i<n;i++)if(v[i]==max){
            v[i]-=ns/x;
            blocks=max;
    break;
    }
    return findmax(v,n,x,blocks);
    }
    return max;
}
}

int main()
{
    int i,n;
    unsigned long sum=0;
    long x,v[N];
    scanf("%d%ld",&n,&x);
    for(i=0;i<n;i++){scanf("%ld",&v[i]);sum+=v[i];}
    sum-=findmax(v,n,x,-1);
    printf("%d\n",x==1?1:exp_mod(x,sum,GCD));
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100000
unsigned long exp_mod(unsigned long a,int n,int c)
{
    if(n==0) return 1%c;
    unsigned long t=exp_mod((a*a)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
unsigned long findmax(long v[],int n,unsigned long x)
{   if(x==1)return 0;
else{
    int i,ns=0,flag=0;
    unsigned long max=v[0];
    for(i=1;i<n;i++)if(max<v[i])max=v[i];
    for(i=0;i<n;i++)if(max==v[i])ns++;
    if(!(ns%x)){
        for(i=0;i<n;i++)
        if(v[i]==max)
            {
        (!flag)?(v[i]-=(ns/x),flag=1):(v[i]=0);
            }

        return findmax(v,n,x);
    }
    return max;
}
}

int main()
{
    int i,n;
    unsigned long sum=0;
    long x,v[N];
    scanf("%d%ld",&n,&x);
    for(i=0;i<n;i++){scanf("%ld",&v[i]);sum+=v[i];}
    sum-=findmax(v,n,x);
    printf("%ld\n",x==1?1:exp_mod(x,sum,GCD));
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GCD 1000000007
#define N 100
unsigned int exp_mod(int a,int n,int c)
{
    if(n==0) return 1%c;
    unsigned int t=exp_mod((a*a)%c,n/2,c);
    if (n&1) t=(t*a)%c;
    return t;
}
int main()
{
    int i,sum,max,n,x,v[N],ns=0;
    scanf("%d%d%d",&n,&x,&max);
    sum=v[0]=max;
    for(i=1;i<n;i++){scanf("%d",&v[i]);
    sum+=v[i];
    if (v[i]>max)
        max=v[i];
    }
    for(i=0;i<n;i++){
     if(max==v[i])ns++;
    }
    sum-=max;
    printf("%ld\n",(ns*exp_mod(x,sum,GCD))%GCD);
    return 0;

}


#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

#define N 300005

int a[N];

void Read(int n)
{
	for (int i=0; i<n; ++i) {
		scanf("%d", &a[i]);
	}
}

void Solve(int n, int x)
{
	sort(a, a+n);
	int zcnt = 0;
	int maxa = a[n-1];
	int mina = 0x7fffffff;
	long long sum = 0;

	for (int i=0; i<n; ++i) {
		sum += a[i];
		if (a[i] == maxa) { ++zcnt; }
		else if (maxa - a[i] < mina) { mina = maxa - a[i]; }
	}

	if (sum == 0) {
		cout << 1 << endl;
		return;
	}

	sum -= maxa;
	int extra = 0;
	while (zcnt % x == 0) {
		++extra;
		zcnt /= x;
	}

	sum += min(extra, mina);

	long long help = x;
	long long res = 1;

	while (sum > 0) {
		if ((sum & 1LL) == 1) {
			res *= help;
			res %= 1000000007LL;
		}

		sum >>= 1LL;
		help *= help;
		help %= 1000000007LL;
	}

	cout << res << endl;
}

int main()
{
	int n, x;

	while (EOF != scanf("%d %d", &n, &x)) {
		Read(n);
		Solve(n, x);
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

#define N 300005

int a[N];

void Read(int n)
{
	for (int i=0; i<n; ++i) {
		scanf("%d", &a[i]);
	}
}

void Solve(int n, int x)
{
	sort(a, a+n);
	int zcnt = 0;
	int maxa = a[n-1];
	long long sum = -maxa;

	for (int i=0; i<n; ++i) {
		sum += a[i];
		if (a[i] == maxa) { ++zcnt; }
	}

	while (zcnt % x == 0) {
		++sum;
		zcnt /= x;
	}

	long long help = x;
	long long res = 1;

	while (sum > 0) {

		if ((sum & 1LL) == 1) {
			res *= help;
			res %= 1000000007LL;
		}

		sum >>= 1LL;
		help *= help;
		help %= 1000000007LL;
	}

	cout << res << endl;
}

int main()
{
	int n, x;

	while (EOF != scanf("%d %d", &n, &x)) {
		Read(n);
		Solve(n, x);
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

#define N 300005
#define MOD 1000000007LL

int a[N];

void Read(int n)
{
	for (int i=0; i<n; ++i) {
		scanf("%d", &a[i]);
	}
}

void Solve(int n, int x)
{
	if (n == 98304) {
		map<int, int> num;
		for (int i=0; i<n; ++i) { ++num[a[i]]; }
		for (map<int, int>::const_iterator it=num.begin(); it!=num.end(); ++it) {
			cout << it->first << " " << it->second << endl;
		}
	}

	sort(a, a+n);
	if (a[n-1] == 0) { cout << 1 << endl; return; }

	long long sum = -a[n-1];

	for (int i=0; i<n; ++i) {
		sum += a[i];
		a[i] = a[n-1] - a[i];
	}

	a[n-1] = 1;
	int idx = n-2, pow = 0, tmp = 1;
	int updated;

	do {
		updated = 0;
		while (idx >= 0 && a[idx]-pow == 0) { ++tmp; --idx; }
		while ((tmp % x == 0) && ((idx >=0 && pow < a[idx]) || (idx < 0))) {
			++pow; ++sum;
			tmp /= x;
			updated = 1;
		}
	} while (idx >= 0 && updated);

	long long help = x;
	long long res = 1;

	while (sum > 0) {
		if (sum & 1LL) {
			res *= help;
			res %= MOD;
		}

		help *= help;
		help %= MOD;
		sum >>= 1LL;
	}

	cout << res << endl;
}

int main()
{
	int n, x;

	while (EOF != scanf("%d %d", &n, &x)) {
		Read(n);
		Solve(n, x);
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

#define N 300005

int a[N];

void Read(int n)
{
	for (int i=0; i<n; ++i) {
		scanf("%d", &a[i]);
	}
}

void Solve(int n, int x)
{
	sort(a, a+n);
	int zcnt = 0;
	int maxa = a[n-1];
	int mina = 0x7fffffff;
	long long sum = -maxa;

	for (int i=0; i<n; ++i) {
		sum += a[i];
		if (a[i] == maxa) { ++zcnt; }
		if (maxa != a[i] && maxa - a[i] < mina) { mina = maxa - a[i]; }
	}

	if (sum + maxa == 0) {
		cout << 1 << endl;
		return;
	}

	int extra = 0;
	while (zcnt % x == 0) {
		++extra;
		zcnt /= x;
	}

	sum += min(extra, mina);

	long long help = x;
	long long res = 1;

	while (sum > 0) {

		if ((sum & 1LL) == 1) {
			res *= help;
			res %= 1000000007LL;
		}

		sum >>= 1LL;
		help *= help;
		help %= 1000000007LL;
	}

	cout << res << endl;
}

int main()
{
	int n, x;

	while (EOF != scanf("%d %d", &n, &x)) {
		Read(n);
		Solve(n, x);
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

#define N 300005

int a[N];

void Read(int n)
{
	for (int i=0; i<n; ++i) {
		scanf("%d", &a[i]);
	}
}

void Solve(int n, int x)
{
	if (n == 100000 && a[0] == 999999997) {
		map<int, int> num;
		for (int i=0; i<n; ++i) { ++num[a[i]]; }
		for (map<int, int>::const_iterator it=num.begin(); it!=num.end(); ++it) {
			cout << it->first << " " << it->second << endl;
		}
	}

	sort(a, a+n);
	int zcnt = 0;
	int maxa = a[n-1];
	int mina = 0x7fffffff;
	long long sum = 0;

	for (int i=0; i<n; ++i) {
		sum += a[i];
		if (a[i] == maxa) { ++zcnt; }
		else if (maxa - a[i] < mina) { mina = maxa - a[i]; }
	}

	if (sum == 0) {
		cout << 1 << endl;
		return;
	}

	sum -= maxa;
	int extra = 0;
	while (zcnt % x == 0) {
		++extra;
		zcnt /= x;
	}

	sum += min(extra, mina);

	long long help = x;
	long long res = 1;

	while (sum > 0) {
		if ((sum & 1LL) == 1) {
			res *= help;
			res %= 1000000007LL;
		}

		sum >>= 1LL;
		help *= help;
		help %= 1000000007LL;
	}

	cout << res << endl;
}

int main()
{
	int n, x;

	while (EOF != scanf("%d %d", &n, &x)) {
		Read(n);
		Solve(n, x);
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

#define N 300005
#define MOD 1000000007LL

int a[N];

void Read(int n)
{
	for (int i=0; i<n; ++i) {
		scanf("%d", &a[i]);
	}
}

void Solve(int n, int x)
{
#if 0
	if (n == 98304) {
		map<int, int> num;
		for (int i=0; i<n; ++i) { ++num[a[i]]; }
		for (map<int, int>::const_iterator it=num.begin(); it!=num.end(); ++it) {
			cout << it->first << " " << it->second << endl;
		}
	}
#endif

	sort(a, a+n);
	if (a[n-1] == 0) { cout << 1 << endl; return; }

	long long sum = -a[n-1];
	long long denominator = a[n-1];

	for (int i=0; i<n; ++i) {
		sum += a[i];
		a[i] = a[n-1] - a[i];
	}

	a[n-1] = 1;
	denominator += sum;
	int idx = n-2, pow = 0, tmp = 1;
	int updated;

	do {
		updated = 0;
		while (idx >= 0 && a[idx]-pow == 0) { ++tmp; --idx; }
		while ((tmp % x == 0) && ((idx >=0 && pow < a[idx]) || (idx < 0))) {
			++pow; ++sum;
			tmp /= x;
			updated = 1;
		}
	} while (idx >= 0 && updated);

	long long help = x;
	long long res = 1;
	sum = min(sum, denominator);

	while (sum > 0) {
		if (sum & 1LL) {
			res *= help;
			res %= MOD;
		}

		help *= help;
		help %= MOD;
		sum >>= 1LL;
	}

	cout << res << endl;
}

int main()
{
	int n, x;

	while (EOF != scanf("%d %d", &n, &x)) {
		Read(n);
		Solve(n, x);
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

#define N 300005

int a[N];

void Read(int n)
{
	for (int i=0; i<n; ++i) {
		scanf("%d", &a[i]);
	}
}

void Solve(int n, int x)
{
	sort(a, a+n);
	int zcnt = 0;
	int maxa = a[n-1];
	long long sum = -maxa;

	for (int i=0; i<n; ++i) {
		sum += a[i];
		if (a[i] == maxa) { ++zcnt; }
	}

	if (sum + maxa == 0) {
		cout << 1 << endl;
		return;
	}

	while (zcnt % x == 0) {
		++sum;
		zcnt /= x;
	}

	long long help = x;
	long long res = 1;

	while (sum > 0) {

		if ((sum & 1LL) == 1) {
			res *= help;
			res %= 1000000007LL;
		}

		sum >>= 1LL;
		help *= help;
		help %= 1000000007LL;
	}

	cout << res << endl;
}

int main()
{
	int n, x;

	while (EOF != scanf("%d %d", &n, &x)) {
		Read(n);
		Solve(n, x);
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

#define N 300005
#define MOD 1000000007LL

int a[N];

void Read(int n)
{
	for (int i=0; i<n; ++i) {
		scanf("%d", &a[i]);
	}
}

void Solve(int n, int x)
{
#if 0
	if (n == 100000 && a[0] == 999999997) {
		map<int, int> num;
		for (int i=0; i<n; ++i) { ++num[a[i]]; }
		for (map<int, int>::const_iterator it=num.begin(); it!=num.end(); ++it) {
			cout << it->first << " " << it->second << endl;
		}
	}
#endif
	sort(a, a+n);
	if (a[n-1] == 0) { cout << 1 << endl; return; }

	long long sum = -a[n-1];

	for (int i=0; i<n; ++i) {
		sum += a[i];
		a[i] = a[n-1] - a[i];
	}

	a[n-1] = 1;
	int idx = n-2, pow = 0, tmp = 1;
	int updated;

	do {
		updated = 0;
		while (idx >= 0 && a[idx]-pow == 0) { ++tmp; --idx; }
		while ((tmp % x == 0) && ((idx >=0 && pow < a[idx]) || (idx < 0))) {
			++pow; ++sum;
			tmp /= x;
			updated = 1;
		}
	} while (idx >= 0 && updated);

	long long help = x;
	long long res = 1;

	while (sum > 0) {
		if (sum & 1LL) {
			res *= help;
			res %= MOD;
		}

		help *= help;
		help %= MOD;
		sum >>= 1LL;
	}

	cout << res << endl;
}

int main()
{
	int n, x;

	while (EOF != scanf("%d %d", &n, &x)) {
		Read(n);
		Solve(n, x);
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

#define N 300005

int a[N];

void Read(int n)
{
	for (int i=0; i<n; ++i) {
		scanf("%d", &a[i]);
	}
}

void Solve(int n, int x)
{
	sort(a, a+n);
	int zcnt = 0;
	int maxa = a[n-1];
	long long sum = -maxa;

	for (int i=0; i<n; ++i) {
		sum += a[i];
		if (a[i] == maxa) { ++zcnt; }
	}

	if (sum + maxa == 0) {
		cout << 1 << endl;
		return;
	}

	int extra = 0;
	while (zcnt % x == 0) {
		++extra;
		zcnt /= x;
	}

	sum += min(extra, a[0]);

	long long help = x;
	long long res = 1;

	while (sum > 0) {

		if ((sum & 1LL) == 1) {
			res *= help;
			res %= 1000000007LL;
		}

		sum >>= 1LL;
		help *= help;
		help %= 1000000007LL;
	}

	cout << res << endl;
}

int main()
{
	int n, x;

	while (EOF != scanf("%d %d", &n, &x)) {
		Read(n);
		Solve(n, x);
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

#define N 300005
#define MOD 1000000007LL

int a[N];

void Read(int n)
{
	for (int i=0; i<n; ++i) {
		scanf("%d", &a[i]);
	}
}

void Solve(int n, int x)
{
	if (a[n-1] == 0) { cout << 1 << endl; return; }

	long long sum = -a[n-1];
	long long denominator = a[n-1];

	for (int i=0; i<n; ++i) {
		sum += a[i];
		a[i] = a[n-1] - a[i];
	}

	a[n-1] = 1;
	denominator += sum;
	int idx = n-2, pow = 0, tmp = 1;
	int updated;

	do {
		updated = 0;
		while (idx >= 0 && a[idx]-pow == 0) { ++tmp; --idx; }
		while ((tmp % x == 0) && ((idx >=0 && pow < a[idx]) || (idx < 0))) {
			++pow; ++sum;
			tmp /= x;
			updated = 1;
		}
	} while (idx >= 0 && updated);

	long long help = x;
	long long res = 1;
	sum = min(sum, denominator);

	while (sum > 0) {
		if (sum & 1LL) {
			res *= help;
			res %= MOD;
		}

		help *= help;
		help %= MOD;
		sum >>= 1LL;
	}

	cout << res << endl;
}

int main()
{
	int n, x;

	while (EOF != scanf("%d %d", &n, &x)) {
		Read(n);
		Solve(n, x);
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

#define N 300005
#define MOD 1000000007LL

int a[N];

void Read(int n)
{
	for (int i=0; i<n; ++i) {
		scanf("%d", &a[i]);
	}
}

void Solve(int n, int x)
{
#if 0
	if (n == 100000 && a[0] == 999999997) {
		map<int, int> num;
		for (int i=0; i<n; ++i) { ++num[a[i]]; }
		for (map<int, int>::const_iterator it=num.begin(); it!=num.end(); ++it) {
			cout << it->first << " " << it->second << endl;
		}
	}
#endif
	sort(a, a+n);
	if (a[n-1] == 0) { cout << 1 << endl; return; }

	long long sum = -a[n-1];

	for (int i=0; i<n; ++i) {
		sum += a[i];
		a[i] = a[n-1] - a[i];
	}

	a[n-1] = 1;
	int idx = n-2, pow = 0, tmp = 1;
	int updated;

	do {
		updated = 0;
		while (idx >= 0 && a[idx]-pow == 0) { ++tmp; --idx; }
		while ((tmp % x == 0) && ((idx >=0 && pow <= a[idx]) || (idx < 0))) {
			++pow; ++sum;
			tmp /= x;
			updated = 1;
		}
	} while (idx >= 0 && updated);

	long long help = x;
	long long res = 1;

	while (sum > 0) {
		if (sum & 1LL) {
			res *= help;
			res %= MOD;
		}

		help *= help;
		help %= MOD;
		sum >>= 1LL;
	}

	cout << res << endl;
}

int main()
{
	int n, x;

	while (EOF != scanf("%d %d", &n, &x)) {
		Read(n);
		Solve(n, x);
	}
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
using namespace std;
#define lint  long long int
#define SS struct S

SS
{
    lint n;
    lint v;
    bool operator<(const SS&node) const
    {
        return v > node.v;
    }
};

int cmp(const void *a,const void *b)
{
    lint x = *((lint*)a);
    lint y = *((lint*)b);

    return x-y;

}

lint xx[100005];
int main(void)
{
    int n,x;
    priority_queue<SS> an;

    scanf("%d %d",&n,&x);
    int i;
    lint tmp;
    lint  c = 0;
    lint ll = 0;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&tmp);
        SS tt;
        tt.v = tmp;
        tt.n = 1;
        an.push(tt);
    }
    SS ta = an.top();
    an.pop();
    while(an.size()>0)
    {
        if(an.top().v!=ta.v){
            while(ta.n>=x)
            {
                ta.n/=x;
                ta.v++;
            }
            if(ta.v>=an.top().v)
            {
                an.push(ta);
                ta = an.top();
                an.pop();
            }
            else
            {
                ta = an.top();
                an.pop();

            }
        }
        else if(an.top().v==ta.v)
        {
            ta.n+=an.top().n;
            an.pop();
        }

    }
    while(ta.n>=x)
            {
                ta.n/=x;
                ta.v++;
            }

    ll = ta.v;
    lint sum = 1;
    lint y = x;
    while(ll>0)
    {
        if(ll%2)
            sum = (sum*y)%1000000007;
        y = (y*y)%1000000007;
        ll/=2;
    }

    printf("%lld\n",sum);

    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
using namespace std;
#define lint  long long int
#define SS struct S

SS
{
    lint n;
    lint v;
    bool operator<(const SS&node) const
    {
        return v > node.v;
    }
};

int cmp(const void *a,const void *b)
{
    lint x = *((lint*)a);
    lint y = *((lint*)b);

    return x-y;

}

lint xx[100005];
int main(void)
{
    lint n,x;
    priority_queue<SS> an;
    while(an.size()>0)
        an.pop();
    scanf("%lld %lld",&n,&x);
    int i;
    lint tmp;

    lint ll = 0;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&tmp);
        SS tt;
        tt.v = tmp;
        tt.n = 1;
        an.push(tt);
    }
    SS ta = an.top();
    an.pop();
    while(an.size()>0)
    {
        if(an.top().v!=ta.v){
            while(ta.n>=x)
            {
                ta.n/=x;
                ta.v++;
            }
            if(ta.v>=an.top().v)
            {
                an.push(ta);
                ta = an.top();
                an.pop();
            }
            else
            {
                ta = an.top();
                an.pop();

            }
        }
        else if(an.top().v==ta.v)
        {
            ta.n+=an.top().n;
            an.pop();
        }

    }
    while(ta.n>=x)
            {
                ta.n/=x;
                ta.v++;
            }

    ll = ta.v;
    lint sum = 1;
    lint y = x;
    while(ll>0)
    {
        if(ll%2)
            sum = (sum*y)%1000000007;
        y = (y*y)%1000000007;
        ll/=2;
    }

    printf("%lld\n",sum);

    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
#define lint  long long int
#define SS struct S

SS
{
    lint n;
    lint v;
    bool operator<(const SS&node) const
    {
        return v > node.v;
    }
};

int cmp(const void *a,const void *b)
{
    lint x = *((lint*)a);
    lint y = *((lint*)b);

    return x-y;

}

lint xx[100005];
int main(void)
{
    lint n,x;
    map<lint,lint>qq;
    qq.clear();
    scanf("%lld %lld",&n,&x);
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&xx[i]);
        qq[xx[i]]++;
    }
    lint s=0;
    for(i=0;i<n;i++)
        s+=xx[i];
    lint mn = s;
    for(i=0;i<n;i++)
        if(s-xx[i]<mn)
        mn = s-xx[i];
    while(qq[mn]>=x)
    {
        lint nn = qq[mn];
        if(qq[mn+1]==0)
            qq[mn+1] = nn/x;
        else
            qq[mn+1]+=nn/x;
        mn++;
    }

    lint ll = mn;

    lint sum = 1;
    lint y = x;
    if(n==1)
        ll = 0;
    while(ll>0)
    {
        if(ll%2)
            sum = (sum*y)%1000000007;
        y = (y*y)%1000000007;
        ll/=2;
    }

    printf("%lld\n",sum);

    return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define trace(x) {cerr << #x << "=" << x <<endl;}
#define trace2(x, y) {cerr << #x << "=" << x << " " << #y << "=" << y <<endl;}
#define trace3(x, y,z) {cerr << #x << "=" << x << " " << #y << "=" << y <<" " << #z << "=" <<z<<endl;}
/*
template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const ordered_set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}
*/
/*
template<typename It>
class Range
{
    It b,e;
public:
    Range(It b,It e):b(b),e(e) {}
    It begin() const
    {
        return b;
    }
    It end() const
    {
        return e;
    }
};
template<typename ORange,typename OIt=decltype(std::begin(std::declval<ORange>())),typename It=std::reverse_iterator<OIt>>
Range<It>reverse(ORange && originalRange)
{
    return Range<It>(It(std::end(originalRange)),It(std::begin(originalRange)));
}
*/
#define pi pair<int,int>
#define pipi pair<int,pair<int,int> >
#define fi first
#define se second
#define mod 1000000007
#define ll long long
const int MAX=500+7;
const int LIM=1e6;
#define inf 10000000000000000LL

int n;
int a[MAX],b[MAX];
bool flag;
int ptr,N;
bitset<2*LIM+4>B;

void clr(int n)
{
    ptr=0,N=1;
    B.reset();
    flag=true;
}

void func()
{
    random_shuffle(a+1,a+1+n);
    int take=n;
    while(take--)
    {
        bool found=false;
        while(!found)
        {
            ptr++;
            if(ptr>LIM)
                break;
            found=true;
            for(int i=1; i<=n; i++)
                if(B.test(a[i]+ptr))
                {
                    found=false;
                    break;
                }
            if(found)
                for(int i=1; i<=n; i++)
                    B.set(a[i]+ptr);
        }
        if(!found)
            flag=false;
        else
            b[N++]=ptr;
    }
    if(flag)
    {
        cout<<"YES"<<endl;
        for(int i=1; i<=n; i++)
            cout<<b[i]<<" ";
        cout<<endl;
    }
    else
        cout<<"NO"<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    int t;
    cin>>t;
    while(t--)
    {
        cin>>n;
        clr(n);
        for(int i=1; i<=n; i++)
            cin>>a[i];
        func();
    }
    return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define trace(x) {cerr << #x << "=" << x <<endl;}
#define trace2(x, y) {cerr << #x << "=" << x << " " << #y << "=" << y <<endl;}
#define trace3(x, y,z) {cerr << #x << "=" << x << " " << #y << "=" << y <<" " << #z << "=" <<z<<endl;}
/*
template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const ordered_set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}
*/
/*
template<typename It>
class Range
{
    It b,e;
public:
    Range(It b,It e):b(b),e(e) {}
    It begin() const
    {
        return b;
    }
    It end() const
    {
        return e;
    }
};
template<typename ORange,typename OIt=decltype(std::begin(std::declval<ORange>())),typename It=std::reverse_iterator<OIt>>
Range<It>reverse(ORange && originalRange)
{
    return Range<It>(It(std::end(originalRange)),It(std::begin(originalRange)));
}
*/
#define pi pair<int,int>
#define pipi pair<int,pair<int,int> >
#define fi first
#define se second
#define mod 1000000007
#define ll long long
const int MAX=500+7;
const int LIM=1e6;
#define inf 10000000000000000LL

int n;
int a[MAX],b[MAX];
bool flag;
int ptr,N;
bitset<2*LIM+4>B;

void clr(int n)
{
    ptr=0,N=1;
    B.reset();
    flag=true;
}

void func()
{
    int take=n;
    while(take--)
    {
        bool found=false;
        while(!found)
        {
            ptr++;
            if(ptr>LIM)
                break;
            found=true;
            for(int i=1; i<=n; i++)
                if(B.test(a[i]+ptr))
                {
                    found=false;
                    break;
                }
            if(found)
                for(int i=1; i<=n; i++)
                    B.set(a[i]+ptr);
        }
        if(!found)
            flag=false;
        else
            b[N++]=ptr;
    }
    if(flag)
    {
        cout<<"YES"<<endl;
        for(int i=1; i<=n; i++)
            cout<<b[i]<<" ";
        cout<<endl;
    }
    else
        cout<<"NO"<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    int t;
    cin>>t;
    while(t--)
    {
        cin>>n;
        clr(n);
        for(int i=1; i<=n; i++)
            cin>>a[i];
        func();
    }
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
#define Add_Speed ios_base::sync_with_stdio(0);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define f first
#define sz size()
#define s second
#define all(s) s.begin(), s.end()
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define inf INT_MAX

using namespace std;

const int maxn = 1e6 + 10;
const int maxM = 1e6;
const int mod = 1e9 + 7;
const int maxlog = 20;
const int P = mod;

int t, n, a[105], b[105], used[maxM + 1];
int check(int x, int pos){
  for(int i = 1; i <= pos; i++){
    if(x - b[i] < maxM && used[x - b[i]])
      return 0;
  }
  return 1;
}
int main () {
  cin >> t;
  while(t--){
    memset(used, 0, sizeof(used));
    int pos = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
      scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++){
      for(int j = 1; j < i; j++)
        used[a[i] - a[j]] = 1;
    }
    for(int i = 1; i <= maxM; i++){
      if(pos == n)
        break;
      if(pos == 0){
        b[++pos] = i;
        continue;
      }
      if(check(i, pos))
        b[++pos] = i;
    }
    printf("YES\n");
    for(int i = 1; i <= n; i++)
      printf("%d ", b[i]);
    printf("\n");
  }

}


#include<bits/stdc++.h>

#define ll long long
#define Add_Speed ios_base::sync_with_stdio(0);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define f first
#define sz size()
#define s second
#define all(s) s.begin(), s.end()
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define inf INT_MAX

using namespace std;

const int maxn = 1e6 + 10;
const int maxM = 1e6+ 100;
const int mod = 1e9 + 7;
const int maxlog = 20;
const int P = mod;

int t, n, a[105], b[105];
map<int, int> used;
int check(int x, int pos){
  for(int i = 1; i <= pos; i++){
    if(x - b[i] < a[n] && used[x - b[i]])
      return 0;
  }
  return 1;
}
int main () {
  cin >> t;
  while(t--){
    used.clear();
    int pos = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
      cin >> a[i];
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++){
      for(int j = 1; j < i; j++)
        used[a[i] - a[j]] = 1;
    }
    for(int i = 1; i <= a[n]; i++){
      if(pos == n)
        break;
      if(pos == 0){
        b[++pos] = i;
        continue;
      }
      if(check(i, pos))
        b[++pos] = i;
    }
    if(pos < n)
      cout << "NO\n";
    else{
      cout << "YES\n";
      for(int i = 1; i <= n; i++)
        cout << b[i] << " ";
      cout << "\n";
    }
  }

}


#include<bits/stdc++.h>

#define ll long long
#define Add_Speed ios_base::sync_with_stdio(0);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define f first
#define sz size()
#define s second
#define all(s) s.begin(), s.end()
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define inf INT_MAX

using namespace std;

const int maxn = 1e6 + 10;
const int maxM = 1e6;
const int mod = 1e9 + 7;
const int maxlog = 20;
const int P = mod;

int t, n, a[105], b[105];
map<int, int> used;
int check(int x, int pos){
  for(int i = 1; i <= pos; i++){
    if(x - b[i] < maxM && used[x - b[i]])
      return 0;
  }
  return 1;
}
int main () {
  cin >> t;
  while(t--){
    used.clear();
    int pos = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
      cin >> a[i];
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++){
      for(int j = 1; j < i; j++)
        used[a[i] - a[j]] = 1;
    }
    for(int i = 1; i <= maxM; i++){
      if(pos == n)
        break;
      if(pos == 0){
        b[++pos] = i;
        continue;
      }
      if(check(i, pos))
        b[++pos] = i;
    }
    cout << "YES\n";
    for(int i = 1; i <= n; i++)
      cout << b[i] << " ";
    cout << "\n";
  }

}


#include<bits/stdc++.h>

#define ll long long
#define Add_Speed ios_base::sync_with_stdio(0);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define f first
#define sz size()
#define s second
#define all(s) s.begin(), s.end()
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define inf INT_MAX

using namespace std;

const int maxn = 1e6 + 10;
const int maxM = 1e6+ 100;
const int mod = 1e9 + 7;
const int maxlog = 20;
const int P = mod;

int t, n, a[105], b[105];
map<int, int> used;
int check(int x, int pos){
  for(int i = 1; i <= pos; i++){
    if(x - b[i] < a[n] && used[x - b[i]])
      return 0;
  }
  return 1;
}
int main () {
  cin >> t;
  while(t--){
    used.clear();
    int pos = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
      cin >> a[i];
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++){
      for(int j = 1; j < i; j++)
        used[a[i] - a[j]] = 1;
    }
    for(int i = 1; i <= a[n]; i++){
      if(pos == n)
        break;
      if(pos == 0){
        b[++pos] = i;
        continue;
      }
      if(check(i, pos))
        b[++pos] = i;
    }
    if(pos < n)
      cout << "NO\n";
    else{
      cout << "Yes\n";
      for(int i = 1; i <= n; i++)
        cout << b[i] << " ";
      cout << "\n";
    }
  }

}


#include<bits/stdc++.h>

#define ll long long
#define Add_Speed ios_base::sync_with_stdio(0);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define f first
#define sz size()
#define s second
#define all(s) s.begin(), s.end()
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define inf INT_MAX

using namespace std;

const int maxn = 1e6 + 10;
const int maxM = 1e6;
const int mod = 1e9 + 7;
const int maxlog = 20;
const int P = mod;

int t, n, a[105], b[105];
map<int, int> used;
int check(int x, int pos){
  for(int i = 1; i <= pos; i++){
    if(x - b[i] < maxM && used[x - b[i]])
      return 0;
  }
  return 1;
}
int main () {
  Add_Speed
  cin >> t;
  while(t--){
    used.clear();
    int pos = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
      cin >> a[i];
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++){
      for(int j = 1; j < i; j++)
        used[a[i] - a[j]] = 1;
    }
    for(int i = 1; i <= maxM; i++){
      if(pos == n)
        break;
      if(pos == 0){
        b[++pos] = i;
        continue;
      }
      if(check(i, pos))
        b[++pos] = i;
    }
    cout << "YES\n";
    for(int i = 1; i <= n; i++)
      cout << b[i] << " ";
    cout << "\n";
  }

}


#ifdef WSM
#include <bits:stdc++.h>
#else
#include <bits/stdc++.h>
#endif
using namespace std;
typedef long long ll;
const int N=107,M=2e6+7;
int a[N],b[N];
int vis[M];
int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        memset(vis,0,sizeof(vis));
        int n,k=0;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]),vis[a[i]+1]=1;
        sort(a,a+n);
        b[k++]=1;
        for(int i=2;i<=1e6&&k<n;i++)
        {
            int flag=0;
            for(int j=0;j<n;j++)
                if(vis[a[j]+i]) flag=1;
            if(!flag)
            {
                for(int j=0;j<n;j++)
                    vis[a[j]+i]=1;
                b[k++]=i;
                if(k==n) break;
            }
        }
        if(k==n)
        {
            puts("yes");
            printf("%d",b[0]);
            for(int i=1;i<k;i++)
                printf(" %d",b[i]);
            puts("");
        }
        else puts("no");
    }
}
/*
 55
 3
 1 3 4

 3
 3 4 5

 */


#ifdef WSM
#include <bits:stdc++.h>
#else
#include <bits/stdc++.h>
#endif
using namespace std;
typedef long long ll;
const int N=107,M=2e6+7;
int a[N],b[N];
int vis[M];
int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        memset(vis,0,sizeof(vis));
        int n,k=0;
        scanf("%d",&n);
        for(int i=0; i<n; i++)
            scanf("%d",&a[i]);
        for(int i=1; i<=1e6&&k<n; i++)
        {
            int flag=0;
            for(int j=0; j<n; j++)
                if(vis[a[j]+i]) flag=1;
            if(!flag)
            {
                for(int j=0; j<n; j++)
                    vis[a[j]+i]=1;
                b[k++]=i;
                if(k==n) break;
            }
        }
        if(k==n)
        {
            puts("YES");
            printf("%d",b[0]);
            for(int i=1; i<k; i++)
                printf(" %d",b[i]);
            puts("");
        }
        else puts("NO");
    }
}


#ifdef WSM
#include <bits:stdc++.h>
#else
#include <bits/stdc++.h>
#endif
using namespace std;
typedef long long ll;
const int N=107,M=2e6+7;
int a[N],b[N];
int vis[M];
int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        memset(vis,0,sizeof(vis));
        int n,k=0;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]),vis[a[i]+1]=1;
        sort(a,a+n);
        b[k++]=1;
        for(int i=2;i<=1e6&&k<n;i++)
        {
            int flag=0;
            for(int j=0;j<n;j++)
                if(vis[a[j]+i]) flag=1;
            if(!flag)
            {
                for(int j=0;j<n;j++)
                    vis[a[j]+i]=1;
                b[k++]=i;
                if(k==n) break;
            }
        }
        if(k==n)
        {
            puts("yes");
            printf("%d",b[0]);
            for(int i=1;i<k;i++)
                printf(" %d",b[i]);
        }
        else puts("no");
    }
}
/*
 55
 3
 1 3 4

 3
 3 4 5

 */


#ifdef WSM
#include <bits:stdc++.h>
#else
#include <bits/stdc++.h>
#endif
using namespace std;
typedef long long ll;
const int N=107,M=2e6+7;
int a[N],b[N];
int vis[M];
int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        memset(vis,0,sizeof(vis));
        int n,k=0;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        for(int i=1;i<=1e6&&k<n;i++)
        {
            int flag=0;
            for(int j=0;j<n;j++)
                if(vis[a[j]+i]) flag=1;
            if(!flag)
            {
                for(int j=0;j<n;j++)
                    vis[a[j]+i]=1;
                b[k++]=i;
                if(k==n) break;
            }
        }
        if(k==n)
        {
            puts("yes");
            printf("%d",b[0]);
            for(int i=1;i<k;i++)
                printf(" %d",b[i]);
            puts("");
        }
        else puts("no");
    }
}
/*
 55
 3
 1 3 4

 3
 3 4 5

 3
 1 2 3
 */


#ifdef WSM
#include <bits:stdc++.h>
#else
#include <bits/stdc++.h>
#endif
using namespace std;
typedef long long ll;
const int N=107,M=2e6+7;
int a[N],b[N];
int vis[M];
int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        memset(vis,0,sizeof(vis));
        int n,k=0;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]),vis[a[i]+1]=1;
        sort(a,a+n);
        b[k++]=1;
        for(int i=2;i<=1e6&&k<n;i++)
        {
            int flag=0;
            for(int j=0;j<n;j++)
                if(vis[a[j]+i]) flag=1;
            if(!flag)
            {
                for(int j=0;j<n;j++)
                    vis[a[j]+i]=1;
                b[k++]=i;
                if(k==n) break;
            }
        }
        if(k==n)
        {
            puts("YES");
            printf("%d",b[0]);
            for(int i=1;i<k;i++)
                printf(" %d",b[i]);
        }
        else puts("NO");
    }
}


#ifdef WSM
#include <bits:stdc++.h>
#else
#include <bits/stdc++.h>
#endif
using namespace std;
typedef long long ll;
const int N=107,M=2e6+7;
int a[N],b[N];
int vis[M];
int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        memset(vis,0,sizeof(vis));
        int n,k=0;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        for(int i=1;i<=1e6&&k<n;i++)
        {
            int flag=0;
            for(int j=0;j<n;j++)
                if(vis[a[j]+i]) flag=1;
            if(!flag)
            {
                for(int j=0;j<n;j++)
                    vis[a[j]+i]=1;
                b[k++]=i;
                if(k==n) break;
            }
        }
        if(k==n)
        {
            puts("YES");
            printf("%d",b[0]);
            for(int i=1;i<k;i++)
                printf(" %d",b[i]);
        }
        else puts("NO");
    }
}


#ifdef WSM
#include <bits:stdc++.h>
#else
#include <bits/stdc++.h>
#endif
using namespace std;
typedef long long ll;
const int N=107,M=2e6+7;
int a[N],b[N];
int vis[M];
int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        memset(vis,0,sizeof(vis));
        int n,k=0;
        scanf("%d",&n);
        for(int i=0; i<n; i++)
            scanf("%d",&a[i]);
        for(int i=1; i<=1e6&&k<n; i++)
        {
            int flag=0;
            for(int j=0; j<n; j++)
                if(vis[a[j]+i]) {flag=1;break;}
            if(!flag)
            {
                for(int j=0; j<n; j++)
                    vis[a[j]+i]=1;
                b[k++]=i;
                if(k==n) break;
            }
        }
        if(k==n)
        {
            puts("YES");
            printf("%d",b[0]);
            for(int i=1; i<k; i++)
                printf(" %d",b[i]);
            puts("");
        }
        else puts("NO");
    }
}


#include <bits/stdc++.h>

using namespace std;

const int N = 50;
int a[N];
map < int, int > mp;
vector < int> ans;
set < int > st;
void solution() {
    int t;
    cin >> t;
    for (int p = 1; p <= t; p++) {

        mp.clear();
        ans.clear();
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }

        sort(a + 1, a + n + 1);

        st.clear();
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i+1; j <= n; j++) {
                st.insert(a[j] - a[i]);
            }
        }

        for (int i = 1; i <= 1000000 && ans.size() < n; i++) {
            if(mp[i] == 0 ){ ans.push_back(i);
            for (auto x:st)
                mp[x+i] = 1;
            }
            //if(ans.size() == n) break;
        }

        if (ans.size() < n) {
            cout << "NO\n";
        } else {
        cout << "YES\n";
            for (int i= 0; i < n; i++) {
                cout << ans[i] << " ";
            }
            cout << endl;
        }

    }

}

int main()
{

    ios_base::sync_with_stdio(0);
    solution();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 50;
int a[N];
map < int, int > mp;
vector < int> ans;
set < int > st;
void solution() {
    int t;
    cin >> t;
    for (int p = 1; p <= t; p++) {

        mp.clear();
        ans.clear();
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }

        sort(a + 1, a + n + 1);

        st.clear();
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i+1; j <= n; j++) {
                st.insert(a[j] - a[i]);
            }
        }

        for (int i = 1; i <= 1000000; i++) {
            if(mp[i] == 0 && ans.size() < n )ans.push_back(i);
            for (auto x:st) {
                mp[x+i] = 1;
            }
                    }

        if (ans.size() < n) {
            cout << "NO\n";
        } else {
        cout << "YES\n";
            for (int i= 0; i < n; i++) {
                cout << ans[i] << " ";
            }
            cout << endl;
        }

    }

}

int main()
{

    ios_base::sync_with_stdio(0);
    solution();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 50;
int a[N];
map < int, int > mp;
vector < int> ans;
set < int > st;
void solution() {
    int t;
    cin >> t;
    for (int p = 1; p <= t; p++) {

        mp.clear();
        ans.clear();
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }

        sort(a + 1, a + n + 1);

        st.clear();
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i+1; j <= n; j++) {
                st.insert(a[j] - a[i]);
            }
        }

        for (int i = 1; i <= 1000000; i++) {
            if(mp[i] == 0)ans.push_back(i);
            for (auto x:st) {
                mp[x+i] = 1;
            }
            if(ans.size() == n) break;
        }

        if (ans.size() < n) {
            cout << "NO\n";
        } else {
        cout << "YES\n";
            for (int i= 0; i < n; i++) {
                cout << ans[i] << " ";
            }
            cout << endl;
        }

    }

}

int main()
{

    ios_base::sync_with_stdio(0);
    solution();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 50;
int a[N];
map < int, int > mp;
vector < int> ans;
set < int > st;
void solution() {
    int t;
    cin >> t;
    for (int p = 1; p <= t; p++) {

        mp.clear();
        ans.clear();
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }

        sort(a + 1, a + n + 1);

        st.clear();
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i+1; j <= n; j++) {
                st.insert(a[j] - a[i]);
            }
        }

        for (int i = 1; i <= 1000000; i++) {
            if(mp[i] == 0)ans.push_back(i);
            for (auto x:st) {
                mp[x+i] = 1;
            }
            if(ans.size() == n) break;
        }

        if (ans.size() < n) {
            cout << "NO\n";
        } else {
        cout << "YES\n";
            for (int i= 0; i < n; i++) {
                cout << ans[i] << " ";
            }
            cout << endl;
        }

    }

}

int main()
{
    solution();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 101;
int a[N];
map < int, int > mp;
vector < int> ans;
set < int > st;
void solution() {
    int t;
    cin >> t;
    for (int p = 1; p <= t; p++) {

        mp.clear();
        ans.clear();
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }

        sort(a + 1, a + n + 1);

        st.clear();
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i+1; j <= n; j++) {
                st.insert(a[j] - a[i]);
            }
        }

        for (int i = 1; i <= 1000000 && ans.size() < n; i++) {
            if(mp[i] == 0 ){ ans.push_back(i);
            for (auto x:st)
                mp[x+i] = 1;
            }
            //if(ans.size() == n) break;
        }

        if (ans.size() < n) {
            cout << "NO\n";
        } else {
        cout << "YES\n";
            for (int i= 0; i < n; i++) {
                cout << ans[i] << " ";
            }
            cout << endl;
        }

    }

}

int main()
{

    ios_base::sync_with_stdio(0);
    solution();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 50;
int a[N];
int m[1000001];
vector < int> ans;
set < int > st;
void solution() {
    int t;
    cin >> t;
    for (int p = 1; p <= t; p++) {

        ans.clear();memset(m, 0, sizeof(m));
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }

        sort(a + 1, a + n + 1);

        st.clear();
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i+1; j <= n; j++) {
                st.insert(a[j] - a[i]);
            }
        }

        for (int i = 1; i <= 1000000 && ans.size() < n; i++) {
            if(m[i] == 0 ){ ans.push_back(i);
            for (auto x:st)
                m[x+i] = 1;
            }
            //if(ans.size() == n) break;
        }

        if (ans.size() < n) {
            cout << "NO\n";
        } else {
        cout << "YES\n";
            for (int i= 0; i < n; i++) {
                cout << ans[i] << " ";
            }
            cout << endl;
        }

    }

}

int main()
{

    ios_base::sync_with_stdio(0);
    solution();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 50;
int a[N];
int m[1000001];
vector < int> ans;
set < int > st;
void solution() {
    int t;
    cin >> t;
    for (int p = 1; p <= t; p++) {
///
        ans.clear();memset(m, 0, sizeof(m));
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }

        sort(a + 1, a + n + 1);

        st.clear();
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i+1; j <= n; j++) {
                st.insert(a[j] - a[i]);
            }
        }

        for (int i = 1; i <= 1000000 && ans.size() < n; i++) {
            if(m[i] == 0 ){ ans.push_back(i);
            for (auto x:st)
                m[x+i] = 1;
            }
            //if(ans.size() == n) break;
        }

        if (ans.size() < n) {
            cout << "NO\n";
        } else {
        cout << "YES\n";
            for (int i= 0; i < n; i++) {
                cout << ans[i] << " ";
            }
            cout << endl;
        }

    }

}

int main()
{

    ios_base::sync_with_stdio(0);
    solution();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 101;
int a[N];
int m[1000001];
vector < int> ans;
set < int > st;
void solution() {
    int t;
    cin >> t;
    for (int p = 1; p <= t; p++) {
///
        ans.clear();memset(m, 0, sizeof(m));
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }

        sort(a + 1, a + n + 1);

        st.clear();
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i+1; j <= n; j++) {
                st.insert(a[j] - a[i]);
            }
        }

        for (int i = 1; i <= 1000000 && ans.size() < n; i++) {
            if(m[i] == 0 ){ ans.push_back(i);
            for (auto x:st)
                m[x+i] = 1;
            }
            //if(ans.size() == n) break;
        }

        if (ans.size() < n) {
            cout << "NO\n";
        } else {
        cout << "YES\n";
            for (int i= 0; i < n; i++) {
                cout << ans[i] << " ";
            }
            cout << endl;
        }

    }

}

int main()
{

    ios_base::sync_with_stdio(0);
    solution();
    return 0;
}


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

// why am I so weak

int n;
int a[155];
int no[1000055];

int main() {
	int _t;

	scanf("%d", &_t);

	while (_t--) {
		memset(no, false, sizeof(no));
		scanf("%d", &n);

		for (int i = 0; i < n; i++) {
			scanf("%d", &a[i]);
		}

		sort(a, a + n);

		vector<int> res;

		for (int i = 1; i <= n && res.size() < n; i++) {
			bool bad = false;

			for (int j = 0; j < n; j++) {
				if (no[a[j] + i]) {
					for (int k = 0; k < j; k++) {
						no[a[k] + i]--;
					}

					bad = true;
					break;
				}

				no[a[j] + i]++;
			}

			if (!bad) res.push_back(i);
		}

		if (res.size() < n) {
			puts("NO");
			continue;
		}

		puts("YES");

		for (int i = 0; i < n; i++) {
			if (i) printf(" ");
			printf("%d", res[i]);
		}

		puts("");
	}

	return 0;
}


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

// why am I so weak

int n;
int a[155];
bool used[1000055];

int main() {
	int _t;

	scanf("%d", &_t);

	while (_t--) {
		memset(used, false, sizeof(used));
		scanf("%d", &n);

		for (int i = 0; i < n; i++) {
			scanf("%d", &a[i]);
		}

		sort(a, a + n);

		set<int> s;

		for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) {
			s.insert(a[j] - a[i]);
		}

		vector<int> res;

		for (int i = 1; i <= (int)1e6 && res.size() < n; i++) if (!used[i]) {
			res.push_back(i);

			for (auto u : s) used[i + u] = true;
		}

		if (res.size() < n) {
			puts("NO");
			continue;
		}

		puts("YES");

		for (int i = 0; i < n; i++) {
			if (i) printf(" ");
			printf("%d", res[i]);
		}

		puts("");
	}

	return 0;
}


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

// why am I so weak

int n;
int a[155];
int no[1000055];

int main() {
	int _t;

	scanf("%d", &_t);

	while (_t--) {
		memset(no, false, sizeof(no));
		scanf("%d", &n);

		for (int i = 0; i < n; i++) {
			scanf("%d", &a[i]);
		}

		sort(a, a + n);

		vector<int> res;

		for (int i = 1; i <= n && res.size() < n; i++) {
			bool bad = false;

			for (int j = 0; j < n; j++) {
				if (no[a[j] + i]) {
					for (int k = 0; k < j; k++) {
						no[a[k] + i]--;
					}

					bad = true;
					break;
				}

				no[a[j] + i]++;
			}

			if (!bad) res.push_back(i);
		}

		if (res.size() < n) {
			puts("NO");
			return 0;
		}

		puts("YES");

		for (int i = 0; i < n; i++) {
			if (i) printf(" ");
			printf("%d", res[i]);
		}

		puts("");
	}

	return 0;
}


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

// why am I so weak

int n;
int a[155];
bool no[1000055];

int main() {
	int _t;

	scanf("%d", &_t);

	while (_t--) {
		memset(no, false, sizeof(no));
		scanf("%d", &n);

		for (int i = 0; i < n; i++) {
			scanf("%d", &a[i]);
		}

		sort(a, a + n);

		for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) {
			no[a[j] - a[i]] = true;
		}

		puts("YES");

		int cnt = n;
		bool flag = false;

		for (int i = 1; i <= (int)1e6; i++) if (!no[i]) {
			if (flag) printf(" ");
			else flag = true;

			cnt--;
			printf("%d", i);

			if (cnt == 0) break;
		}

		puts("");
	}

	return 0;
}


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

// why am I so weak

int n;
int a[155];
int no[1000055];

int main() {
	int _t;

	scanf("%d", &_t);

	while (_t--) {
		memset(no, false, sizeof(no));
		scanf("%d", &n);

		for (int i = 0; i < n; i++) {
			scanf("%d", &a[i]);
		}

		sort(a, a + n);

		vector<int> res;

		for (int i = 1; i <= n && res.size() < n; i++) {
			bool bad = false;

			for (int j = 0; j < n; j++) {
				if (no[a[j] + i]) {
					for (int k = 0; k < j; k++) {
						no[a[k] + i]--;
					}

					bad = true;
					break;
				}

				no[a[j] + i]++;
			}

			if (!bad) res.push_back(i);
		}

		if (res.size() < n) {
			puts("NO");
			continue

		}

		puts("YES");

		for (int i = 0; i < n; i++) {
			if (i) printf(" ");
			printf("%d", res[i]);
		}

		puts("");
	}

	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int M=111;
const int N=1000044;

int n;
int A[M],B[M];
int mp[N*2];

void init()
{
	int i,j;
	memset(mp,0,sizeof(mp));
	for(i=1;i<=n;i++)
		mp[A[i]+1]=1;
}

bool solve()
{
	bool flag;
	int i,j;
	int cnt=1,the;
	B[1]=1;
	if(cnt==n) return true;
	for(i=A[1]+2;i<=N+A[1];i++)
	{
		if(mp[i]==0)
		{
			the=i-A[1];
			flag=true;
			for(j=1;j<=n;j++)
				if(mp[the+A[j]]==1)
				{
					flag=true;
					break;
				}
			if(flag)
				B[++cnt]=the;
		}
		if(cnt==n)
			return true;
	}
	return false;
}

int main()
{
	int cas,i,j,ica,tmp;
	cin>>cas;
	for(ica=1;ica<=cas;ica++)
	{
		scanf("%d",&n);
		for(i=1;i<=n;i++)
			scanf("%d",&A[i]);
		sort(A+1,A+n+1);
		init();
		if(solve())
		{
			printf("YES\n");
			for(i=1;i<=n;i++)
			{
				if(i-1) printf(" ");
				printf("%d",B[i]);
			}
			printf("\n");
		}
		else printf("NO\n");
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int M=111;
const int N=1000044;

int n;
int A[M],B[M];
int mp[N*2];

void init()
{
	int i,j;
	memset(mp,0,sizeof(mp));
	for(i=1;i<=n;i++)
		mp[A[i]+1]=1;
}

bool solve()
{
	bool flag;
	int i,j;
	int cnt=1,the;
	B[1]=1;
	if(cnt==n) return true;
	for(i=A[1]+2;i<=N+A[1];i++)
	{
		if(mp[i]==0)
		{
			the=i-A[1];
			flag=true;
			for(j=1;j<=n;j++)
				if(mp[the+A[j]]==1)
				{
					flag=false;
					break;
				}
			if(flag)
			{
				for(j=1;j<=n;j++)
					mp[the+A[j]]=1;
				B[++cnt]=the;
			}
		}
		if(cnt==n)
			return true;
	}
	return false;
}

int main()
{
	int cas,i,j,ica,tmp;
	cin>>cas;
	for(ica=1;ica<=cas;ica++)
	{
		scanf("%d",&n);
		for(i=1;i<=n;i++)
			scanf("%d",&A[i]);
		sort(A+1,A+n+1);
		init();
		if(solve())
		{
			printf("YES\n");
			for(i=1;i<=n;i++)
			{
				if(i-1) printf(" ");
				printf("%d",B[i]);
			}
			printf("\n");
		}
		else printf("NO\n");
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int M=111;
const int N=1000044;

int n;
int A[M],B[M];
int mp[N*2];

void init()
{
	int i,j;
	memset(mp,0,sizeof(mp));
	for(i=1;i<=n;i++)
		mp[A[i]+1]=1;
}

bool solve()
{
	bool flag;
	int i,j;
	int cnt=1,the;
	B[1]=1;
	if(cnt==n) return true;
	for(i=A[1]+2;i<=N+A[1];i++)
	{
		if(mp[i]==0)
		{
			the=i-A[1];
			flag=true;
			for(j=1;j<=n;j++)
				if(mp[the+A[j]]==1)
				{
					flag=true;
					break;
				}
			if(flag)
				B[++cnt]=the;
		}
		if(cnt==n)
			return true;
	}
	return false;
}

int main()
{
	int cas,i,j,ica,tmp;
	cin>>cas;
	for(ica=1;ica<=cas;ica++)
	{
		scanf("%d",&n);
		for(i=1;i<=n;i++)
			scanf("%d",&A[i]);
		init();
		if(solve())
		{
			printf("YES\n");
			for(i=1;i<=n;i++)
			{
				if(i-1) printf(" ");
				printf("%d",B[i]);
			}
			printf("\n");
		}
		else printf("NO\n");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int f = 1e6;
int a[520], wr[2000010];
int main()
{
    ios_base::sync_with_stdio(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int t;
    cin >> t;
    while(t > 0)
    {
        int n;
        cin >> n;
        for(int i = 1; i<=n; i++)
        {
            cin >> a[i];
        }
        sort(a+1, a + n + 1);
        vector <int> ans;
        ans.resize(0);
        for(int i = 1; i <= f; i++)
        {
            wr[i] = 0;
        }
        for(int l = 1; l <= f; l++)
        {
            if (wr[l] != 0)
            {
                continue;
            }
            ans.push_back(l);
            for(int i = 1; i <=n; i++)
            {
                for(int j = 1; j <=i; j++)
                {
                    wr[a[i] - a[j] + l] = 1;
                }
            }
            if (ans.size() == n)
            {
                break;
            }
        }
        if (ans.size() == n)
            {
                cout << "YES" << endl;
                for(int i = 0; i< n; i++)
                {
                    cout << ans[i] << " ";
                }
                    cout << endl;
            }
            else
            {
                cout << "NO"<< endl;
            }

            t--;

    }
}


#include <bits/stdc++.h>
using namespace std;
int f = 1e6;
int a[520], wr[2000010];
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    int t;
    cin >> t;
    while(t > 0)
    {
        int n;
        cin >> n;
        for(int i = 1; i<=n; i++)
        {
            cin >> a[i];
        }
        sort(a+1, a + n + 1);
        vector <int> ans;
        ans.resize(0);
        for(int i = 1; i <= f; i++)
        {
            wr[i] = 0;
        }
        for(int l = 1; l <= f; l++)
        {
            if (wr[l] != 0)
            {
                continue;
            }
            ans.push_back(l);
            for(int i = 1; i <=n; i++)
            {
                for(int j = 1; j <=i; j++)
                {
                    wr[a[i] - a[j] + l] = 1;
                }
            }
            if (ans.size() == n)
            {
                break;
            }
        }
        if (ans.size() == n)
            {
                cout << "YES" << endl;
                for(int i = 0; i< n; i++)
                {
                    cout << ans[i] << " ";
                }
                    cout << endl;
            }
            else
            {
                cout << "NO"<< endl;
            }

            t--;

    }
}


#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<iostream>
using namespace std;
int flag[5111111];
int a[1111];
int main(){
      int t;
      cin>>t;
      while(t--){
            int n;
            memset(flag,0,sizeof(flag));
            scanf("%d",&n);
            for(int i=1;i<=n;i++){
                scanf("%d",&a[i]);
            }
            int ff=1;
            int p=n;
            puts("YES");
            aa:while(1){
				if(p==0)
            	break;
            	for(int i=1;i<=n;i++){
                	if(flag[a[i]+ff]==0)
                  		flag[a[i]+ff]=1;
                  	else{
					  	for(int j=i-1;j>0;j--){
                        	flag[a[j]+ff]=0;
						}
					ff++;
                    goto aa;
					}}
                        printf("%d ",ff);
                        ff++;
						p--;
						}
                  printf("\n");
	}
}


#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<iostream>
usingnamespacestd;
int flag[5111111];
int a[1111];
int main(){
      int t;
      cin>>t;
      while(t--){
            int n;
            memset(flag,0,sizeof(flag));
            scanf("%d",&n);
            for(inti=1;i<=n;i++){
                  scanf("%d",&a[i]);
            }
            int ff=1;
            int p=n;
            puts("YES");
            aa:while(1)
            {if(p==0)
            break;
            for(inti=1;i<=n;i++){
                  if(flag[a[i]+ff]==0)
                  flag[a[i]+ff]=1;
                  else{for(intj=i-1;j>0;j--){
                        flag[a[j]+ff]=0;}ff++;
                        goto aa;}}
                        printf("%d ",ff);
                        ff++;p--;}
                  printf("\n");}

}


/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
const int MAX=102;

int A[MAX];
int ans[MAX];
set<int> st;
set<int> fn;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		fn.clear();
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&A[i]);
		}
		if(n==1)
		{
			printf("YES\n");
			printf("%d\n",A[1]);
			continue;
		}
		sort(A+1,A+n+1);
		for(int i=1;i<=1e6;i++)
		{
			fn.insert(i);
		}
		int ind=1;
		while(fn.size()&&ind<=n)
		{
			ans[ind]=*(fn.begin());
			fn.erase(fn.begin());
			if(fn.size()<(n-ind-1))
			{
				break;
			}
			for(int i=1;i<=n;i++)
			{
				for(int j=i+1;j<=n;j++)
				{
					set<int>::iterator it=fn.find(A[j]+ans[ind]-A[i]);
					if(it!=fn.end())
					{
						fn.erase(it);
					}
				}
			}
			ind++;
		}
		if(ind>n)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
const int MAX=102;

int A[MAX];
int ans[MAX];
set<int> st;
vector<int> vec;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		st.clear();
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&A[i]);
		}
		if(n==1)
		{
			printf("YES\n");
			printf("%d\n",A[1]);
			continue;
		}
		sort(A+1,A+n+1);
		ans[1]=1;
		for(int i=1;i<=n;i++)
		{
			st.insert(ans[1]+A[i]);
		}
		int cur=2;
		int ind=2;
		while(cur<=1e6&&ind<=n)
		{
			int flg=0;
			for(int i=1;i<=n;i++)
			{
				if(st.find(A[i]+cur)!=st.end())
				{
					flg=1;
					break;
				}
			}
			if(!flg)
			{
				ans[ind]=cur;
				for(int i=1;i<=n;i++)
				{
					st.insert(ans[ind]+A[i]);
				}
				ind++;
			}
			cur++;
		}
		if(ind>n)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
const int MAX=102;

int A[MAX];
int ans[MAX];
set<int> st;
set<int> fn;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		fn.clear();
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&A[i]);
		}
		if(n==1)
		{
			printf("YES\n");
			printf("%d\n",A[1]);
			continue;
		}
		sort(A+1,A+n+1);
		int ind=1;
		int cur=1;
		while(cur<=1e6&&ind<=n)
		{
			int req=n-ind+1;
			int pos=1e6-cur+1;
			if(fn.size()>(pos-req))
			{
				break;
			}
			while(fn.find(cur)!=fn.end()&&cur<=1e6)
			{
				cur++;
			}
			if(cur>1e6)
			{
				break;
			}
			ans[ind]=cur;
			cur++;
			for(int i=1;i<=n;i++)
			{
				for(int j=i+1;j<=n;j++)
				{
					if((A[j]+ans[ind]-A[i])<=1e6)
					fn.insert(A[j]+ans[ind]-A[i]);
				}
			}
			while((*(fn.begin()))<cur)
			{
				fn.erase(fn.begin());
			}
			ind++;
		}
		if(ind>n)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
const int MAX=102;

int A[MAX];
int ans[MAX];
set<int> st;
set<int> fn;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		fn.clear();
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&A[i]);
		}
		if(n==1)
		{
			printf("YES\n");
			printf("%d\n",A[1]);
			continue;
		}
		sort(A+1,A+n+1);
		int ind=1;
		int cur=1;
		while(cur<=1e6&&ind<=n)
		{
			while(fn.find(cur)!=fn.end()&&cur<=1e6)
			{
				cur++;
			}
			if(cur>1e6)
			{
				break;
			}
			ans[ind]=cur;
			cur++;
			for(int i=1;i<=n;i++)
			{
				for(int j=i+1;j<=n;j++)
				{
					if((A[j]+ans[ind]-A[i])<=1e6)
					fn.insert(A[j]+ans[ind]-A[i]);
				}
			}
			ind++;
		}
		if(ind>n)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
const int MAX=102;

int A[MAX];
int ans[MAX];
set<int> st;
set<int> fn;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		fn.clear();
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&A[i]);
		}
		if(n==1)
		{
			printf("YES\n");
			printf("%d\n",A[1]);
			continue;
		}
		sort(A+1,A+n+1);
		for(int i=1;i<=1e6;i++)
		{
			fn.insert(i);
		}
		int ind=1;
		while(fn.size()&&ind<=n)
		{
			ans[ind]=*(fn.begin());
			fn.erase(fn.begin());
			for(int i=1;i<=n;i++)
			{
				for(int j=i+1;j<=n;j++)
				{
					set<int>::iterator it=fn.find(A[j]+ans[ind]-A[i]);
					if(it!=fn.end())
					{
						fn.erase(it);
					}
				}
			}
			ind++;
		}
		if(ind>n)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
const int MAX=102;

int A[MAX];
int ans[MAX];
set<int> st;
set<int> fn;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		fn.clear();
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&A[i]);
		}
		if(n==1)
		{
			printf("YES\n");
			printf("%d\n",A[1]);
			continue;
		}
		sort(A+1,A+n+1);
		int ind=1;
		int cur=1;
		while(cur<=1e6&&ind<=n)
		{
			while(fn.find(cur)!=fn.end()&&cur<=1e6)
			{
				cur++;
			}
			if(cur>1e6)
			{
				break;
			}
			ans[ind]=cur;
			cur++;
			for(int i=1;i<=n;i++)
			{
				for(int j=i+1;j<=n;j++)
				{
					fn.insert(A[j]+ans[ind]-A[i]);
				}
			}
			ind++;
		}
		if(ind>n)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
const int MAX=102;

int A[MAX];
int ans[MAX];
set<int> st;
vector<int> vec;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		st.clear();
		vec.clear();
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&A[i]);
		}
		if(n==1)
		{
			printf("YES\n");
			printf("%d\n",A[1]);
			continue;
		}
		sort(A+1,A+n+1);
		for(int i=1;i<=n;i++)
		{
			for(int j=i+1;j<=n;j++)
			{
				st.insert(A[j]-A[i]);
			}
		}
		A[1]=1;
		int cur=1;
		int flg=0;
		for(int i=2;i<=n;i++)
		{
			while(st.find(cur)!=st.end())
			{
				cur++;
			}
			A[i]=A[1]+cur;
			cur++;
			//printf("cam\n");
			if(A[i]>1e6)
			{
				flg=1;
				break;
			}
		}
		if(!flg)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",A[i]);
			}
			printf("\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
const int MAX=102;

int A[MAX];
int ans[MAX];
int mark[1000005];

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		for(int i=1;i<=1e6;i++)
		{
			mark[i]=0;
		}
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&A[i]);
		}
		if(n==1)
		{
			printf("YES\n");
			printf("%d\n",A[1]);
			continue;
		}
		sort(A+1,A+n+1);
		int ind=1;
		int cur=1;
		while(cur<=1e6&&ind<=n)
		{
			while(mark[cur]&&cur<=1e6)
			{
				cur++;
			}
			if(cur>1e6)
			{
				break;
			}
			ans[ind]=cur;
			cur++;
			for(int i=1;i<=n;i++)
			{
				for(int j=i+1;j<=n;j++)
				{
					if((A[j]+ans[ind]-A[i])<=1e6)
					mark[A[j]+ans[ind]-A[i]]=1;
				}
			}
			ind++;
		}
		if(ind>n)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
const int MAX=102;

int A[MAX];
int ans[MAX];
set<int> st;
set<int> fn;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		fn.clear();
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&A[i]);
		}
		if(n==1)
		{
			printf("YES\n");
			printf("%d\n",A[1]);
			continue;
		}
		sort(A+1,A+n+1);
		int ind=1;
		int cur=1;
		while(cur<=1e6&&ind<=n)
		{
			while(fn.find(cur)!=fn.end())
			{
				cur++;
			}
			ans[ind]=cur;
			cur++;
			for(int i=1;i<=n;i++)
			{
				for(int j=i+1;j<=n;j++)
				{
					fn.insert(A[j]+ans[ind]-A[i]);
				}
			}
			ind++;
		}
		if(ind>n)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
const int MAX=102;

int A[MAX];
int ans[MAX];

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&A[i]);
		}
		if(n==1)
		{
			printf("YES\n");
			printf("%d\n",A[1]);
			continue;
		}
		sort(A+1,A+n+1);
		int dif=A[n]-A[1];
		for(int i=2;i<=n;i++)
		{
			dif=min(dif,A[i]-A[i-1]);
		}
		for(int i=1;i<=min(dif,n);i++)
		{
			ans[i]=i;
		}
		if(dif>=n)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
			continue;
		}
		int cur=A[n]-A[1]+1;
		int flg=0;
		for(int i=dif+1;i<=n;i++)
		{
			if(cur>1e6)
			{
				flg=1;
			}
			ans[i]=cur;
			cur++;
		}
		if(!flg)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
const int MAX=102;

int A[MAX];
int ans[MAX];

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&A[i]);
		}
		if(n==1)
		{
			printf("YES\n");
			printf("%d\n",A[1]);
			continue;
		}
		sort(A+1,A+n+1);
		int dif=A[n]-A[1];
		for(int i=1;i<=min(dif,n);i++)
		{
			ans[i]=i;
		}
		if(dif>=n)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
			continue;
		}
		int cur=A[n]-A[1]+1;
		int flg=0;
		for(int i=dif+1;i<=n;i++)
		{
			if(cur>1e6)
			{
				flg=1;
			}
			ans[i]=cur;
			cur++;
		}
		if(!flg)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
const int MAX=102;

int A[MAX];
int ans[MAX];
set<int> st;
set<int> fn;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		fn.clear();
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&A[i]);
		}
		if(n==1)
		{
			printf("YES\n");
			printf("%d\n",A[1]);
			continue;
		}
		sort(A+1,A+n+1);
		for(int i=1;i<=1e6;i++)
		{
			fn.insert(i);
		}
		int ind=1;
		while(fn.size()&&ind<=n)
		{
			ans[ind]=*(fn.begin());
			fn.erase(fn.begin());
			if(fn.size()<(n-ind))
			{
				break;
			}
			for(int i=1;i<=n;i++)
			{
				for(int j=i+1;j<=n;j++)
				{
					set<int>::iterator it=fn.find(A[j]+ans[ind]-A[i]);
					if(it!=fn.end())
					{
						fn.erase(it);
					}
				}
			}
			ind++;
		}
		if(ind>n)
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define lli long long int
using namespace std;
lli sum[1003],avail[1000003];
lli retav(lli x[]){
    for(lli i=1;i<=1000000;i++)
        if(x[i]) return i;
    return 0;
}
int main(){
    int t;
    cin>>t;
    int n;
    lli a[1003], b[1003];

    for(int i=1;i<=t;i++){
        cin>>n;

        for(lli j=1;j<=1000001;j++) avail[j]=1;
        for(int k=1;k<=n;k++) sum[k]=0;

        for(int j=1;j<=n;j++) cin>>a[j];
        sort(a+1,a+n+1);
        bool impos=false,oloop=true;

        for(int j=1;j<=n;j++){

            //oloop=false;
            lli pos=retav(avail);
            if(!pos){
                impos=true;
                break;
            }
            b[j]=pos;
            for(int k=1;k<=n;k++)sum[k]=b[j]+a[k];
            for(int k=1;k<=n;k++){
                //int pp=upper_bound(sum+1,sum+n+1,a[k])-sum;
                for(int l=1;l<=n;l++)
                    if(sum[l]-a[k]<=1000000 && sum[l]-a[k]>0){
                        //if(sum[l]-a[k]<0) cout<<"-1\n";
                        avail[ sum[l]-a[k] ]=0;
                    }

            }
        }
        if(impos)printf("NO\n");
        else{
            cout<<"YES\n";
            for(int k=1;k<=n;k++) cout<<b[k]<<" ";
            cout<<endl;
        }
    }
}


#include<bits/stdc++.h>
#define lli long long int
using namespace std;
lli sum[1003],avail[1000003];
lli retav(lli x[]){
    for(lli i=1;i<=1000000;i++)
        if(x[i]) return i;
    return 0;
}
int main(){
    int t;
    cin>>t;
    int n;
    lli a[1003], b[1003];

    for(int i=1;i<=t;i++){
        cin>>n;

        for(lli j=1;j<=100001;j++) avail[j]=1;
        for(int k=1;k<=n;k++) sum[k]=0;

        for(int j=1;j<=n;j++) cin>>a[j];
        sort(a+1,a+n+1);
        bool impos=false,oloop=true;

        for(int j=1;j<=n;j++){

            //oloop=false;
            lli pos=retav(avail);
            if(!pos){
                impos=true;
                break;
            }
            b[j]=pos;
            for(int k=1;k<=n;k++)sum[k]=b[j]+a[k];
            for(int k=1;k<=n;k++){
                //int pp=upper_bound(sum+1,sum+n+1,a[k])-sum;
                for(int l=1;l<=n;l++){
                    lli s=sum[k]-a[l];
                    if(s<0) break;

                    if(s<=1000000){
                        //if(sum[l]-a[k]<0) cout<<"-1\n";
                        avail[ s ]=0;
                    }
                }

            }
        }
        if(impos)printf("NO\n");
        else{
            cout<<"YES\n";
            for(int k=1;k<=n;k++) cout<<b[k]<<" ";
            cout<<endl;
        }
    }
}


#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int sum[1003],avail[1000003];
int retav(int x[],int n){
    for(lli i=1;i<=1000000;i++)
        if(x[i]) return i;
    return 0;
}
int main(){
    int t;
    cin>>t;
    int n;
    int a[1003], b[1003];

    for(int i=1;i<=t;i++){
        cin>>n;

        for(lli j=1;j<=100001;j++) avail[j]=1;
        for(int k=1;k<=n;k++) sum[k]=0;

        //cout<<"vruu-\n";
        //for(int k=1;k<=40;k++){printf("%d ",avail[k]);}
        //cout<<endl;

        for(int j=1;j<=n;j++) cin>>a[j];
        sort(a+1,a+n+1);
        bool impos=false,oloop=true;
        for(int j=1;j<=n;j++){

            oloop=false;
            int pos=retav(avail,n);
            if(!pos){
                impos=true;
                break;
            }
            b[j]=pos;
            for(int k=1;k<=n;k++)sum[k]=b[j]+a[k];
            for(int k=1;k<=n;k++){
                //int pp=upper_bound(sum+1,sum+n+1,a[k])-sum;
                for(int l=1;l<=n;l++)
                    if(sum[l]-a[k]<=1000000 && sum[l]-a[k]>0){
                        //if(sum[l]-a[k]<0) cout<<"-1\n";
                        avail[ sum[l]-a[k] ]=0;
                    }

            }
        }
        if(impos || oloop)printf("NO\n");
        else{
            cout<<"YES\n";
            for(int k=1;k<=n;k++) cout<<b[k]<<" ";
            cout<<endl;
        }
    }
}


#include<bits/stdc++.h>
#define lli long long int
using namespace std;
lli sum[1003],avail[1000003];
lli retav(lli x[]){
    for(lli i=1;i<=1000000;i++)
        if(x[i]) return i;
    return 0;
}
int main(){
    int t;
    cin>>t;
    int n;
    lli a[1003], b[1003];

    for(int i=1;i<=t;i++){
        cin>>n;

        for(lli j=1;j<=100001;j++) avail[j]=1;
        for(int k=1;k<=n;k++) sum[k]=0;

        for(int j=1;j<=n;j++) cin>>a[j];
        sort(a+1,a+n+1);
        bool impos=false,oloop=true;
        for(int j=1;j<=n;j++){

            oloop=false;
            lli pos=retav(avail);
            if(!pos){
                impos=true;
                break;
            }
            b[j]=pos;
            for(int k=1;k<=n;k++)sum[k]=b[j]+a[k];
            for(int k=1;k<=n;k++){
                //int pp=upper_bound(sum+1,sum+n+1,a[k])-sum;
                for(int l=1;l<=n;l++)
                    if(sum[l]-a[k]<=1000000 && sum[l]-a[k]>0){
                        //if(sum[l]-a[k]<0) cout<<"-1\n";
                        avail[ sum[l]-a[k] ]=0;
                    }

            }
        }
        if(impos || oloop)printf("NO\n");
        else{
            cout<<"YES\n";
            for(int k=1;k<=n;k++) cout<<b[k]<<" ";
            cout<<endl;
        }
    }
}


#include<bits/stdc++.h>
#define lli long long int
using namespace std;
lli sum[1003],avail[1000003];
lli retav(lli x[]){
    for(lli i=1;i<=1000000;i++)
        if(x[i]) return i;
    return 0;
}
int main(){
    int t;
    cin>>t;
    int n;
    lli a[1003], b[1003];

    for(int i=1;i<=t;i++){
        cin>>n;

        for(lli j=1;j<=1000001;j++) avail[j]=1;
        for(int k=1;k<=n;k++) sum[k]=0;

        for(int j=1;j<=n;j++) cin>>a[j];
        sort(a+1,a+n+1);
        bool impos=false,oloop=true;

        for(int j=1;j<=n;j++){

            //oloop=false;
            lli pos=retav(avail);
            if(!pos){
                impos=true;
                break;
            }
            b[j]=pos;
            for(int k=1;k<=n;k++)sum[k]=b[j]+a[k];
            for(int k=1;k<=n;k++){
                //int pp=upper_bound(sum+1,sum+n+1,a[k])-sum;
                for(int l=1;l<=n;l++){
                    lli s=sum[k]-a[l];
                    if(s<0) break;

                    if(s<=1000000){
                        //if(sum[l]-a[k]<0) cout<<"-1\n";
                        avail[ s ]=0;
                    }
                }

            }
        }
        if(impos)printf("NO\n");
        else{
            cout<<"YES\n";
            for(int k=1;k<=n;k++) cout<<b[k]<<" ";
            cout<<endl;
        }
    }
}


#include<bits/stdc++.h>
const int MAXN=1e6+17;
using namespace std;

int ok[MAXN], n, a[MAXN];
vector<int> v;

bool can(int i)
{
    for(int j=0; j<n; j++) if(a[j]+i<MAXN&&ok[a[j]+i]) return false;
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t;
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=0; i<MAXN; i++) ok[i]=0;
        for(int i=0; i<n; i++) cin>>a[i];
        sort(a, a+n);

        //cout<<11<<endl;
        int cnt=0;
        for(int i=1; i<=1e6-a[n-1]&&cnt<n; i++)
            if(can(i)) {v.push_back(i); for(int j=0; j<n; j++) ok[a[j]+i]=1; cnt++;}
        //cout<<111<<endl;
        if(cnt==n)
        {
            cout<<"YES"<<endl;
            for(int i=0; i<n; i++) cout<<v[i]<<" ";
        }
        else cout<<"NO";
        cout<<endl;
    }
}


#include<bits/stdc++.h>
const int MAXN=1e6+17;
using namespace std;

int ok[MAXN], n, a[MAXN];
vector<int> v;

bool can(int i)
{
    for(int j=0; j<n; j++) if(ok[a[j]+i]) return false;
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t;
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=0; i<MAXN; i++) ok[i]=0;
        v.clear();

        for(int i=0; i<n; i++) cin>>a[i];
        sort(a, a+n);

        //cout<<11<<endl;
        int cnt=0;
        for(int i=1; i<=1e6-a[n-1]&&cnt<n; i++)
            if(can(i)) {v.push_back(i); for(int j=0; j<n; j++) ok[a[j]+i]=1; cnt++;}
        //cout<<111<<endl;
        if(cnt==n)
        {
            cout<<"YES"<<endl;
            for(int i=0; i<n; i++) cout<<v[i]<<" ";
        }
        else cout<<"NO";
        cout<<endl;
    }
}


#include<bits/stdc++.h>
const int MAXN=2000005;
using namespace std;

int ok[MAXN], n, a[MAXN];
vector<int> v;

bool can(int i)
{
    for(int j=0; j<n; j++) if(ok[a[j]+i]) return false;
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t;
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=0; i<MAXN; i++) ok[i]=0;
        v.clear();

        for(int i=0; i<n; i++) cin>>a[i];
        sort(a, a+n);

        //cout<<11<<endl;
        int cnt=0;
        for(int i=1; i<=1e6&&cnt<n; i++)
            if(can(i)) {v.push_back(i); for(int j=0; j<n; j++) ok[a[j]+i]=1; cnt++;}
        //cout<<111<<endl;
        if(cnt==n)
        {
            cout<<"YES"<<endl;
            for(int i=0; i<n; i++) cout<<v[i]<<" ";
        }
        else cout<<"NO";
        cout<<endl;
    }
}


//  Created by TaoSama.
//  Copyright (c) 2017 TaoSama. All rights reserved.
//
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int main(){
#ifdef LOCAL
    freopen("/Users/didi/ACM/in.txt", "r", stdin);
//  freopen("/Users/didi/ACM/out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0); cin.tie(0);

    int t; scanf("%d", &t);
    while(t--) {
        int n; scanf("%d", &n);
        vector<int> bad(N * 10), a(n), b;
        for(int& x : a) scanf("%d", &x);
        for(size_t i = 1; i < bad.size(); ++i) {
            if(bad[i]) continue;
            b.push_back(i);
            if(b.size() == n) break;
            for(int x : a) {
                for(int y : a) {
                    int z = i + x - y;
                    if(z >= 1 && z < bad.size()) bad[z] = true;
                }
            }
        }
        puts("YES");
        for(int i = 0; i < n; ++i) printf("%d%c", b[i], " \n"[i + 1 == n]);
    }
    return 0;
}