#include <bits/stdc++.h>
const int P = 1000000007;
using namespace std;
inline void ckmax(int &a, int b) { a = max(a, b); }
inline void ckmin(int &a, int b) { a = min(a, b); }
inline void mulmod(int &a, int b) { a = 1ll * a * b % P; }
inline void addmod(int &a, int b) {
  int t = a + b;
  a = (t >= P ? t - P : t);
}
inline int ksm(int a, long long b) {
  int ans = 1;
  for (; b; b >>= 1) {
    if (b & 1) ans = 1ll * ans * a % P;
    a = 1ll * a * a % P;
  }
  return ans;
}
inline int inv(int a) { return ksm(a, P - 2); }
namespace FastIO {
const int SIZE = 1 << 16;
char buf[SIZE], obuf[SIZE], str[64];
int bi = SIZE, bn = SIZE, opt;
int read(char *s) {
  while (bn) {
    for (; bi < bn && buf[bi] <= ' '; bi++)
      ;
    if (bi < bn) break;
    bn = fread(buf, 1, SIZE, stdin), bi = 0;
  }
  int sn = 0;
  while (bn) {
    for (; bi < bn && buf[bi] > ' '; bi++) s[sn++] = buf[bi];
    if (bi < bn) break;
    bn = fread(buf, 1, SIZE, stdin), bi = 0;
  }
  s[sn] = 0;
  return sn;
}
bool read(int &x) {
  if (x) x = 0;
  int bf = 0, n = read(str);
  if (!n) return 0;
  int i = 0;
  if (str[i] == '-') bf = 1, i = 1;
  for (x = 0; i < n; i++) x = x * 10 + str[i] - '0';
  if (bf) x = -x;
  return 1;
}
void write(int x) {
  if (!x)
    obuf[opt++] = '0';
  else {
    if (x < 0) obuf[opt++] = '-', x = -x;
    int sn = 0;
    while (x) str[sn++] = x % 10 + '0', x /= 10;
    for (int i = sn - 1; i >= 0; i--) obuf[opt++] = str[i];
  }
  if (opt >= (SIZE >> 1)) {
    fwrite(obuf, 1, opt, stdout);
    opt = 0;
  }
}
void write(char x) {
  obuf[opt++] = x;
  if (opt >= (SIZE >> 1)) {
    fwrite(obuf, 1, opt, stdout);
    opt = 0;
  }
}
void Fflush() {
  if (opt) fwrite(obuf, 1, opt, stdout);
  opt = 0;
}
};  // namespace FastIO
const int MAXN = 6005;
int n;
bool isprime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
signed main() {
  cin >> n;
  if (n == 1) {
    printf("-1\n");
  } else if (n == 2) {
    printf("1 1\n");
  } else if (n == 3) {
    printf("1 1 2\n");
  } else {
    int sum = n * (n + 1) / 2;
    if (sum % 2 == 0) {
      for (register int i = (0); i <= (n); i++) {
        if (i == 1) continue;
        if (isprime(i) && isprime(sum - i)) {
          for (register int j = (1); j <= (n); j++) {
            if (i == j)
              printf("2 ");
            else
              printf("1 ");
          }
          exit(0);
        }
      }
    } else {
      if (isprime(sum - 2)) {
        for (register int i = (1); i <= (n); i++) {
          if (i == 2)
            printf("2 ");
          else
            printf("1 ");
        }
        exit(0);
      }
      sum -= 3;
      for (register int i = (1); i <= (n); i++) {
        if (i == 3 || i == 1) continue;
        if (isprime(i) && isprime(sum - i)) {
          for (register int j = (1); j <= (n); j++) {
            if (i == j)
              printf("2 ");
            else if (j != 3)
              printf("1 ");
            else
              printf("3 ");
          }
          exit(0);
        }
      }
    }
  }
  return FastIO::Fflush(), 0;
}
