#include <bits/stdc++.h>
using namespace std;
int read() {
  int sum = 0, fg = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fg = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    sum = (sum << 3) + (sum << 1) + c - '0';
    c = getchar();
  }
  return sum * fg;
}
const int N = 2e7;
int prime[N], cnt;
bool vis[N];
void init(int n) {
  for (int i = 2; i <= n; i++) vis[i] = 0;
  vis[0] = vis[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!vis[i]) {
      cnt++;
      prime[cnt] = i;
    }
    for (int j = 1; j <= cnt && prime[j] * i <= n; j++) {
      vis[prime[j] * i] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int main() {
  int n = read();
  if (n == 2) {
    printf("1 1");
    return 0;
  }
  cnt = 0;
  int m = n * (n + 1) / 2;
  init(m);
  if (m % 2 == 0) {
    int p;
    for (int i = 1; i <= cnt; i++) {
      if (vis[m - prime[i]] == 0) {
        p = prime[i];
        break;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (i == p || i == m - p) {
        printf("2 ");
      } else {
        printf("1 ");
      }
    }
  } else {
    if (vis[m - 2] == 0) {
      for (int i = 1; i <= n; i++) {
        if (i == 2) {
          printf("2 ");
        } else {
          printf("1 ");
        }
      }
    } else {
      m -= 3;
      int p;
      for (int i = 1; i <= cnt; i++) {
        if (vis[m - prime[i]] == 0) {
          p = prime[i];
          break;
        }
      }
      for (int i = 1; i <= n; i++) {
        if (i == 3) {
          printf("3 ");
        } else if (i == p || i == m - p) {
          printf("2 ");
        } else {
          printf("1 ");
        }
      }
    }
  }
  return 0;
}
