#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-9;
const int MAXN = 1000 * 1000;
bool isPrime[MAXN];
int primes[100 * 1000];
int amountPrimes;
bool testPrime(int x) {
  for (int i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      return false;
    }
  }
  return x > 1;
}
void precalc() {
  amountPrimes = 0;
  memset(isPrime, true, sizeof(isPrime));
  isPrime[0] = isPrime[1] = false;
  for (int i = 2; i < MAXN; ++i) {
    if (isPrime[i]) {
      primes[amountPrimes++] = i;
      for (int j = i + i; j < MAXN; j += i) {
        isPrime[j] = false;
      }
    }
  }
  cerr << amountPrimes << endl;
}
vector<int> collect(int remain, int border) {
  vector<int> res;
  for (int cur = border; cur > 0; --cur) {
    if (cur <= remain) {
      res.push_back(cur);
      remain -= cur;
    }
  }
  assert(remain == 0);
  return res;
}
vector<int> solve(int n) {
  int sumAll = n * (n + 1) / 2;
  int minAbleColor = 0;
  if (testPrime(sumAll)) {
    return vector<int>(n, minAbleColor);
  }
  int border = n;
  vector<int> res(n, -1);
  if (sumAll & 1) {
    if (testPrime(sumAll - 2)) {
      res.assign(n, 0);
      res[2 - 1] = 1;
      return res;
    }
    bool ok = false;
    for (int p = n; p > 1; --p) {
      if (testPrime(p)) {
        border = p - 1;
        sumAll -= p;
        res[p - 1] = minAbleColor++;
        ok = true;
        break;
      }
    }
    assert(ok);
  }
  bool ok = false;
  for (int primeId = 0; primeId < amountPrimes; ++primeId) {
    int p = primes[primeId];
    if (2 * p <= sumAll && testPrime(sumAll - p)) {
      assert(border * (border + 1) / 2 >= p);
      vector<int> marked = collect(p, border);
      for (int i = 0; i < marked.size(); ++i) {
        int number = marked[i];
        res[number - 1] = minAbleColor;
      }
      ++minAbleColor;
      ok = true;
      break;
    }
  }
  assert(ok);
  for (int i = 0; i < res.size(); ++i) {
    if (res[i] == -1) {
      res[i] = minAbleColor;
    }
  }
  return res;
}
int main() {
  precalc();
  int n;
  while (cin >> n) {
    cerr << "n = " << n << endl;
    vector<int> res = solve(n);
    for (int i = 0; i < res.size(); ++i) {
      cout << res[i] + 1 << " ";
    }
    cout << endl;
  }
  return 0;
}
