#include <bits/stdc++.h>
using namespace std;
const int N = 2e7 + 2;
int cnt;
int prime[N];
bool flag[N];
void Euler(int n) {
  for (int i = 2; i <= n; i++) {
    if (!flag[i]) prime[++cnt] = i;
    for (int j = 1; j <= cnt && i * prime[j] <= n; j++) {
      flag[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int n;
int ans[6002];
void work(int x, int cur) {
  for (int i = n; i >= 1; --i) {
    if (!ans[i] && i <= x) {
      ans[i] = cur;
      x -= i;
    }
  }
}
int main() {
  Euler(20000000);
  scanf("%d", &n);
  int sum = n * (n + 1) / 2;
  if (!flag[sum]) {
    for (int i = 1; i <= n; ++i) ans[i] = 1;
  } else if (sum & 1) {
    if (!flag[sum - 2]) {
      ans[2] = 1;
      work(sum - 1, 2);
    } else {
      ans[3] = 1;
      for (int i = 1; i <= cnt; ++i) {
        int p1 = prime[i];
        int p2 = sum - 3 - p1;
        if (!flag[p2]) {
          work(p1, 2);
          work(p2, 3);
          break;
        }
      }
    }
  } else {
    for (int i = 1; i <= cnt; ++i) {
      int p1 = prime[i];
      int p2 = sum - p1;
      if (p2 != 1 && !flag[p2]) {
        work(p1, 1);
        work(p2, 2);
        break;
      }
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d%c", ans[i], " \n"[i == n]);
  return 0;
}
