#include <bits/stdc++.h>
using namespace std;
bool is_prime(int a) {
  switch (a) {
    case 1:
      return false;
      break;
    case 2:
      return true;
      break;
    default:
      int i = 2;
      while (i * i <= a) {
        if (!(a % i)) {
          return false;
        }
        i++;
      }
      return true;
      break;
  }
}
int main() {
  int in;
  cin >> in;
  int m, ans[10240];
  m = (in + 1) * in / 2;
  for (int i = 1; i <= in; ++i) {
    ans[i] = 1;
  }
  if (is_prime(m)) {
    for (int i = 1; i <= in; ++i) {
      cout << ans[i] << " ";
    }
    return 0;
  }
  if (m & 1 && !is_prime(m - 2)) {
    ans[3] = 3;
    m -= 3;
  }
  for (int i = 2; i <= in; ++i) {
    if (is_prime(i) && is_prime(m - i)) {
      ans[i] = 2;
      break;
    }
  }
  for (int i = 1; i <= in; ++i) {
    cout << ans[i] << " ";
  }
  return 0;
}
