#include <bits/stdc++.h>
const int N = 18010000;
int vis[N], pri[N], tot;
int n, m, ok;
void pre(int u) {
  pri[++tot] = 2;
  for (int i = 3; i <= u; i += 2) {
    if (vis[i]) continue;
    pri[++tot] = i;
    for (int j = 2; j * i <= u; j++)
      if (!vis[j * i]) vis[j * i] = 1;
  }
}
int main() {
  pre(N - 1);
  scanf("%d", &n);
  if (n <= 2) {
    for (int i = 1; i <= n; i++) printf("1 ");
    return 0;
  }
  m = (1 + n) * n / 2;
  for (int i = 1; i <= tot; i++) {
    if ((!vis[m - pri[i]] && ((m - pri[i]) & 1))) {
      for (int j = 1; j <= n; j++) {
        if (j != pri[i])
          printf("1 ");
        else
          printf("2 ");
      }
      ok = 1;
      break;
    }
  }
  if (ok) return 0;
  for (int i = 1; i < tot; i++)
    if (!ok)
      for (int j = i + 1; j <= tot; j++) {
        if ((!vis[m - pri[i] - pri[j]] && ((m - pri[i] - pri[j]) & 1))) {
          for (int k = 1; k <= n; k++) {
            if (k != pri[i] && k != pri[j])
              printf("1 ");
            else if (k == pri[i])
              printf("2 ");
            else
              printf("3 ");
            ok = 1;
          }
          break;
        }
      }
}
