#include <bits/stdc++.h>
using namespace std;
bool isprime(int x) {
  if (x == 1) return false;
  for (int i = 2; i * i <= x; ++i)
    if (!(x % i)) return false;
  return true;
}
int col[6009];
int main() {
  int n;
  cin >> n, fill(col + 1, col + n + 1, 1);
  int sum = n * (n + 1) >> 1;
  if (!isprime(sum)) {
    if (sum & 1) {
      if (isprime(sum - 2)) {
        col[2] = 2;
        goto print;
      }
      sum -= 3, col[3] = 3;
    }
    for (int i = 3; i <= n; i += 2)
      if (col[i] == 1 && isprime(i) && isprime(sum - i)) {
        col[i] = 2;
        break;
      }
  }
print:
  for (int i = 1; i <= n; ++i) cout << col[i] << " \n"[i == n];
  return 0;
}
