#include <bits/stdc++.h>
int n, g, c[6010];
bool p(int x) {
  if (x == 1) return 0;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  g = n * (n + 1) / 2;
  if ((g & 1) && (n > 2) && !p(g - 2)) c[3] = 2, g -= 3;
  for (int i = 0; i < n + 1; i++)
    if (!c[i] && p(i) && p(g - i)) {
      c[i] = 1;
      break;
    }
  for (int i = 0; i < n; i++) printf("%d ", c[i + 1] + 1);
}
