#include <bits/stdc++.h>
using namespace std;
const int maxn = 6005;
int n, ans[maxn];
bool check(int x) {
  for (int i = 2; i <= sqrt(x); i++)
    if (!(x % i)) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  int m = (n + 1) * n / 2;
  for (int i = 1; i <= n; i++) ans[i] = 1;
  if (check(m)) {
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    printf("\n");
    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;
    }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
