#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p = 0, i, j, N, c3 = 0;
  cin >> n;
  if (n == 2) {
    cout << "1 1";
    return 0;
  }
  N = n * (n + 1) / 2;
  vector<bool> s(N + 1);
  for (i = 2; i * i <= N; i++) {
    if (s[i] == false)
      for (j = i * i; j <= N; j += i) s[j] = true;
  }
  if (N & 1) {
    if (s[N - 2] == false)
      p = 2;
    else
      N -= 3, c3 = 1;
  }
  if (!p) {
    for (i = 2; i <= N / 2; i++) {
      if (s[i] == false && s[N - i] == false) p = i;
    }
  }
  vector<int> color(n + 1, 1);
  i = n;
  while (p) {
    if (p > i)
      color[i] = 2, p -= i, i--;
    else
      color[p] = 2, p = 0;
  }
  if (c3) {
    if (color[3] == 1)
      color[3] = 3;
    else
      color[1] = color[2] = 3;
  }
  for (i = 1; i <= n; i++) cout << color[i] << " ";
}
