#include <bits/stdc++.h>
using namespace std;
int n, sum, color[6010];
inline bool isprime(int x) {
  int la = sqrt(x);
  for (int i = 2; i <= la; ++i) {
    if (x % i == 0) return 0;
  }
  return 1;
}
int main(void) {
  ios::sync_with_stdio(0);
  cin >> n;
  sum = (n + 1) * n / 2;
  for (int i = 1; i <= n; ++i) {
    color[i] = 1;
  }
  if (isprime(sum)) {
    for (int i = 1; i <= n; ++i) {
      cout << color[i] << " ";
    }
    return 0;
  }
  if (!isprime(sum - 2) and (sum & 1)) {
    color[3] = 3;
    sum -= 3;
  }
  for (int i = 2; i <= n; ++i) {
    if (isprime(i) and isprime(sum - i)) {
      color[i] = 2;
      break;
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << color[i] << " ";
  }
  return 0;
}
