
#include<stdio.h>

#include<string.h>
#include<stdlib.h>
#define N 998

int *find_next(int *a) {
  for (int i = 0; i < N; i++) if (a[i] != 0) return a + i;
  return NULL;
}

void kill_mults(int *a, int m) {
  for (int i = 0; i < N; i++) if (a[i] % m == 0) a[i] = 0;
}

int main() {
  // Setup all numbers
  int n[N], *c;
  int p[N], r = 0;
  for (int i = 0; i < N; i++) {
    n[i] = i + 2;
  }

  while (1){
    int *c = find_next(n);
    if ((c = find_next()) == NULL) break;
    p[r++] = *c;
    kill_mults(n, *c);
  }


  for (int i = 0; i < r; i++) {
    printf("%d ", p[i]);

  }

}



