#include <bits/stdc++.h>
using namespace std;
template <typename T>
double DIS(T va, T vb) {
  return sqrt((double)(va.x - vb.x) * (va.x - vb.x) +
              (double)(va.y - vb.y) * (va.y - vb.y));
}
template <class T>
inline T INTEGER_LEN(T v) {
  int len = 1;
  while (v /= 10) ++len;
  return len;
}
template <typename T>
inline T square(T va, T vb) {
  return va * va + vb * vb;
}
#pragma comment(linker, "/STACK:1024000000,1024000000")
int ar[10000];
int N;
bool isprime(int v) {
  for (int i = 2; i * i <= v; ++i) {
    if (v % i == 0) return false;
  }
  return true;
}
void solve(int n) {
  int sum = (n + 1) * n / 2;
  for (int i = 1; i <= n; ++i) ar[i] = 1;
  if (!isprime(sum)) {
    if (sum % 2 == 0) {
      for (int i = 2; i <= n; ++i) {
        if (isprime(i) && isprime(sum - i)) {
          ar[i] = 2;
          break;
        }
      }
    } else {
      if (isprime(sum - 2))
        ar[2] = 2;
      else {
        ar[1] = ar[2] = 3;
        sum -= 3;
        for (int i = 3; i <= n; ++i) {
          if (isprime(i) && isprime(sum - i)) {
            ar[i] = 2;
            break;
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (i > 1) putchar(' ');
    printf("%d", ar[i]);
  }
  printf("\n");
}
int main(void) {
  while (~scanf("%d", &N)) {
    solve(N);
  }
  return 0;
}
