#include <bits/stdc++.h>
int N, M, a[6005];
bool ok(int x) {
  if (x < 2) return 0;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
void work() {
  for (int i = 1; i <= N; i++) a[i] = 1;
  if (ok(M)) return;
  if (M & 1 && !ok(M - 2)) a[3] = 3, M -= 3;
  for (int i = 1; i <= N; i++)
    if (ok(i) && ok(M - i)) {
      a[i] = 2;
      break;
    }
}
int main() {
  scanf("%d", &N), M = (N + 1) * N / 2, work();
  for (int i = 1; i <= N; i++) printf("%d%c", a[i], i == N ? '\n' : ' ');
}
