#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
double fRand(double fMin, double fMax) {
  double f = (double)rand() / RAND_MAX;
  return fMin + f * (fMax - fMin);
}
template <class T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <class T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
long long mul(long long a, long long b) {
  if (a * b / a != b) return 1000000000000000007LL;
  return min(1000000000000000007LL, a * b);
}
int n, ans[6005];
int Find(int sum) {
  for (int i = (n); i >= (1); --i) {
    if (i <= sum) {
      sum -= i;
      ans[i] = 2;
    }
  }
}
bool isPrime(int n) {
  if (n < 2) return false;
  int lim = sqrt(n);
  for (int i = (2); i <= (lim); ++i)
    if (n % i == 0) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) ans[i] = 1;
  int sum = n * (n + 1) / 2;
  if (!isPrime(sum)) {
    if (isPrime(sum - 2)) {
      ans[2] = 2;
      sum -= 2;
    } else {
      if (sum % 2 == 1) {
        ans[3] = 3;
        sum -= 3;
      }
      for (int i = (2); i <= (sum); ++i) {
        if (isPrime(i) && isPrime(sum - i)) {
          Find(i);
          break;
        }
      }
    }
  }
  for (int i = (1); i <= (n); ++i) printf("%d ", ans[i]);
  return 0;
}
