unsigned tmp[100000000];
int cnt[65536];
void sort(unsigned *a, int N)
{
for (int i = 0; i < 65536; i++)
cnt[i] = 0;
for (int i = 0; i < N; i++)
cnt[a[i] & 65535]++;
for (int i = 1; i < 65536; i++)
cnt[i] += cnt[i - 1];
for (int i = N - 1; i >= 0; i--)
tmp[--cnt[a[i] & 65535]] = a[i];
for (int i = 0; i < 65536; i++)
cnt[i] = 0;
for (int i = 0; i < N; i++)
cnt[a[i] >> 16]++;
for (int i = 1; i < 65536; i++)
cnt[i] += cnt[i - 1];
for (int i = N - 1; i >= 0; i--)
a[--cnt[tmp[i] >> 16]] = tmp[i];
}