#include <bits/stdc++.h>
using namespace std;
const int MAXN = 60003;
int isPrime[MAXN];
int prime[MAXN];
int pLen;
int dd[MAXN];
vector<int> vv;
void getPrime(int n) {
  bool fg = 0;
  memset(isPrime, 0, sizeof(isPrime));
  memset(prime, 0, sizeof(prime));
  pLen = 0;
  for (int i = 2; i < MAXN; i++) {
    if (0 == isPrime[i]) {
      prime[pLen++] = i;
      if (!fg && i * i <= MAXN) {
        for (int j = i * i; j < MAXN; j += i) {
          isPrime[j] = 1;
        }
      } else
        fg = 1;
    }
  }
}
void print(int len) {
  for (int i = 1; i <= len; i++) {
    printf("%d ", dd[i]);
  }
  cout << endl;
}
bool isprime2(int v) {
  for (int i = 2; i * i <= v; i++) {
    if (v % i == 0) return false;
  }
  return true;
}
bool find2(int sum, int &x, int &y, int n) {
  for (int i = 0; i < pLen && prime[i] <= n; i++) {
    if (isprime2(sum - prime[i])) {
      x = prime[i];
      y = sum - prime[i];
      return true;
    }
  }
  return false;
}
bool find3(int sum, int &x, int &y, int &z, int n) {
  for (int i = 0; i < pLen && prime[i] < n; i++) {
    for (int j = i + 1; j < pLen && prime[j] < n; j++) {
      if (isprime2(sum - prime[i] - prime[j])) {
        z = sum - prime[i] - prime[j];
        x = prime[i];
        y = prime[j];
        return true;
      }
    }
  }
  return false;
}
void solve(int n) {
  int sum;
  int x, y, z;
  for (int i = 1; i <= n; i++) {
    dd[i] = 1;
  }
  if (n == 1) {
    dd[1] = 2;
    print(1);
    return;
  }
  sum = n * (n + 1) / 2;
  if (isprime2(sum) == 1) {
    print(n);
    return;
  } else if (find2(sum, x, y, n)) {
    dd[x] = 2;
    print(n);
    return;
  } else if (find3(sum, x, y, z, n)) {
    dd[x] = 2;
    dd[y] = 3;
    print(n);
    return;
  } else {
    printf("-1\n");
    return;
  }
}
int main() {
  int n;
  getPrime(MAXN);
  while (scanf("%d", &n) != EOF) {
    solve(n);
  }
  return 0;
}
