#include <bits/stdc++.h>
using namespace std;
int n, sum, ans[6010];
inline bool is_prime(int x) {
  if (x < 2) return false;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
inline void draw(int x) {
  for (int i = 2; i <= x >> 1; i++)
    if (ans[i] == 1 && is_prime(i) && is_prime(x - i)) {
      ans[i] = 2;
      return;
    }
}
int main() {
  scanf("%d", &n);
  sum = (n * (n + 1)) >> 1;
  for (int i = 1; i <= n; i++) ans[i] = 1;
  if (!is_prime(sum)) {
    if (sum & 1) {
      if (is_prime(sum - 2))
        ans[2] = 2;
      else {
        ans[3] = 3;
        draw(sum - 3);
      }
    } else
      draw(sum);
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
