#include <bits/stdc++.h>
using namespace std;
bool* primes(int last) {
  bool* table = new bool[++last];
  for (int i = 0; i < last; ++i) table[i] = i >= 2;
  for (int i = 0; i * i < last; ++i)
    if (table[i])
      for (int j = i * i; j < last; j += i) table[j] = false;
  return table;
}
bool* prime = primes(18003000);
int pdiv(int x) {
  for (int i = 0; i < x; ++i)
    if (prime[i] and prime[x - i]) return i;
  return -1;
}
int main() {
  int n, sum;
  scanf("%d", &n);
  sum = (n + 1) * n / 2;
  if (prime[sum])
    for (int i = 0; i < n; ++i) printf("%d ", 1);
  else {
    int color[n], a, b;
    for (int i = 0; i < n; ++i) color[i] = 0;
    if (sum % 2 == 0)
      a = pdiv(sum), b = sum - a;
    else if (prime[sum - 2]) {
      a = sum - 2, b = 2;
    } else {
      a = pdiv(sum - 3), b = sum - a - 3;
      color[3 - 1] = 3;
    }
    for (int i = n; i > 0; --i)
      if (color[i - 1] == 0) {
        if (a >= i)
          a -= i, color[i - 1] = 1;
        else
          b -= i, color[i - 1] = 2;
      }
    for (int i = 0; i < n; ++i) printf("%d ", color[i]);
  }
  return 0;
}
