void sort(unsigned *a, int n) {
const int mod=100000;
int *c1=new int[mod],*c2=new int[mod];
unsigned *b=new unsigned[n];
for (int i=0;i<mod;++i)
c1[i]=c2[i]=0;
for (int i=0;i<n;++i)
++c1[a[i]/mod],++c2[a[i]%mod];
for (int i=1;i<mod;++i)
c1[i]+=c1[i-1],c2[i]+=c2[i-1];
for (int i=n-1;i>=0;--i)
b[--c2[a[i]%mod]]=a[i];
for (int i=n-1;i>=0;--i)
a[--c1[b[i]/mod]]=b[i];
return;
}