#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 9991;
int ans[6005];
int n;
int cnt = 0;
bool isPrime(int n) {
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return true;
}
void print() {
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
}
int main() {
  cin >> n;
  int m = n * (n + 1) / 2;
  for (int i = 1; i <= n; i++) ans[i] = 1;
  if (isPrime(m)) {
    print();
    return 0;
  } else if (m & 1 && isPrime(m - 2)) {
    ans[2] = 2;
    print();
    return 0;
  } else if (m & 1) {
    m -= 3;
    ans[3] = 3;
  }
  for (int i = 2; i <= n; i++) {
    if (isPrime(i) && isPrime(m - i)) {
      ans[i] = 2;
      break;
    }
  }
  print();
  return 0;
}
