#include <stdio.h>
#include <math.h>

const int mval = 500;
int r[1001];

int coot[501];

int j=0;
int i=0;

int main(){

for(i; i<20; i++){
  r[i] = rand() % 501;
  coot[r[i]]++;
  printf("%i, ", r[i]);
  }

printf("\n");

for(i=0; i<mval; i++)
  while(coot[i]>0){
    r[j] = i;
    coot[i]--;
    j++;
    printf("%i, ", i);
    }
     
return 0;    

}