#include <bits/stdc++.h>
using namespace std;
int n, p[6010], used[6010], cnt = 0, vis[6010];
bool check(int x) {
  for (int i = 2; i <= sqrt(x); i++)
    if (x % i == 0) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  int m = n * (n + 1) / 2;
  used[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!used[i]) p[++cnt] = i;
    for (int j = i * 2; j <= n; j += i) used[j] = 1;
  }
  if (check(m)) {
    for (int i = 1; i <= n; i++) vis[i] = 1;
  } else if (m & 1) {
    if (check(m - 2)) {
      vis[2] = 1;
      vis[1] = 2;
      for (int i = 3; i <= n; i++) vis[i] = 2;
    } else {
      vis[3] = 1;
      for (int i = 1; i <= n; i++)
        if (i != 3 && check(m - i - 3) && !used[i]) {
          vis[i] = 2;
          for (int j = 1; j <= n; j++) {
            if (i == j || j == 3) continue;
            vis[j] = 3;
          }
          break;
        }
    }
  } else {
    for (int i = 1; i <= n; i++)
      if (check(m - i) && !used[i]) {
        vis[i] = 1;
        for (int j = 1; j <= n; j++) {
          if (i == j) continue;
          vis[j] = 2;
        }
        break;
      }
  }
  for (int i = 1; i <= n; i++) printf("%d ", vis[i]);
}
