#include <bits/stdc++.h>
using namespace std;
int n, N, id[6100];
bool judge(int n) {
  if (n < 2) return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
void work() {
  if (judge(N)) return;
  if (N % 2 && !judge(N - 2)) N -= 3, id[3] = 3;
  for (int i = 1; i <= n; i++) {
    if (judge(i) && judge(N - i)) {
      id[i] = 2;
      break;
    }
  }
}
int main() {
  cin >> n;
  N = n * (n + 1) / 2;
  for (int i = 1; i <= n; i++) id[i] = 1;
  if (n == 1) puts("-1");
  work();
  for (int i = 1; i <= n; i++) cout << id[i] << ' ';
  return 0;
}
