#include <bits/stdc++.h>
using namespace std;
const int _ = 6005;
inline int read() {
  char ch = '!';
  int z = 1, num = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') z = -1, ch = getchar();
  while (ch <= '9' && ch >= '0')
    num = (num << 3) + (num << 1) + ch - '0', ch = getchar();
  return z * num;
}
int n, ans[_];
void Print() {
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  puts("");
}
bool check(int x) {
  int q = sqrt(x);
  for (int i = 2; i <= q; ++i)
    if (!(x % i)) return 0;
  return 1;
}
int main() {
  n = read();
  int m = (n + 1) * n / 2;
  for (int i = 1; i <= n; ++i) ans[i] = 1;
  if (check(m)) {
    Print();
    return 0;
  }
  if (m & 1 && !check(m - 2)) ans[3] = 3, m -= 3;
  for (int i = 2; i <= n; ++i)
    if (check(i) && check(m - i)) {
      ans[i] = 2;
      break;
    }
  Print();
  return 0;
}
