#include <bits/stdc++.h>
using namespace std;
bool pri[18003001];
int que[1200000], cnt, n;
int PA1, PA2;
void makepri() {
  memset(pri, 0, sizeof(pri));
  cnt = 0;
  pri[1] = 1;
  for (int i = 2; i < 18003001; ++i) {
    if (!pri[i]) que[++cnt] = i;
    for (int j = 1; j <= cnt; ++j)
      if (i * que[j] < 18003001) {
        pri[i * que[j]] = 1;
        if (i % que[j] == 0) break;
      } else
        break;
  }
}
int main() {
  scanf("%d", &n);
  if (n == 1) {
    printf("1\n");
    return 0;
  }
  if (n == 2) {
    printf("1 1\n");
    return 0;
  }
  makepri();
  PA1 = PA2 = 0;
  int s = (n + 1) * n / 2;
  bool flag = 0;
  for (int j = 1; que[j] <= n; ++j)
    if (!pri[s - que[j]]) {
      flag = 1;
      PA1 = que[j];
      break;
    }
  if (!flag)
    for (int j = 1; que[j] <= n; ++j) {
      for (int k = j + 1; que[k] <= n; ++k)
        if (!pri[s - que[k] - que[j]]) {
          PA1 = que[j];
          PA2 = que[k];
          flag = 1;
          break;
        }
      if (flag) break;
    }
  for (int j = 1; j < n; ++j)
    if (PA1 == j)
      printf("2 ");
    else if (PA2 == j)
      printf("3 ");
    else
      printf("1 ");
  if (PA1 == n)
    printf("2\n");
  else if (PA2 == n)
    printf("3\n");
  else
    printf("1\n");
}
