#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[6100];
bool prime(const int x) {
  for (int i = 2; i * i <= x; ++i)
    if (x % i == 0) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) a[i] = 1;
  m = n * (n + 1) / 2;
  if (!prime(m)) {
    if ((m & 1) && !prime(m - 2)) a[3] = 2, m -= 3;
    for (int i = 2; i < m; ++i)
      if (prime(i) && prime(m - i)) {
        a[i] = a[3] + 1;
        break;
      }
  }
  for (int i = 1; i < n; ++i) printf("%d ", a[i]);
  printf("%d\n", a[n]);
  return 0;
}
