#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return (n > 1);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T = 1;
  while (T--) {
    long long n;
    cin >> n;
    long long col[n + 1];
    for (long long i = 1; i <= n; i++) col[i] = 1;
    long long sum = n * (n + 1) / 2;
    if (sum > 5 && sum % 2 == 1 && !isPrime(sum - 2)) {
      col[3] = 3;
      sum -= 3;
    }
    for (long long i = 1; i <= n; i++) {
      if (col[i] == 1 && isPrime(i) && isPrime(sum - i)) {
        col[i] = 2;
        break;
      }
    }
    for (long long i = 1; i <= n; i++) cout << col[i] << ' ';
    cout << '\n';
  }
  return 0;
}
