#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, top, zhan[19000005], book2[6005], x, y;
bool book[19000005];
int read() {
  char ch = getchar();
  int xx = 0;
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    xx = xx * 10 + ch - '0';
    ch = getchar();
  }
  return xx;
}
int main() {
  n = read();
  if (n == 2) {
    printf("1 1\n");
  } else {
    m = n * (n + 1) / 2;
    book[0] = 1;
    book[1] = 1;
    for (i = 2; i <= m; i++) {
      if (book[i] == 0) {
        top++;
        zhan[top] = i;
      }
      for (j = 1; j <= top && i * zhan[j] <= m; j++) {
        book[i * zhan[j]] = 1;
        if (i % zhan[j] == 0) break;
      }
    }
    if (m & 1) {
      if (book[m] == 0) {
        for (j = 1; j <= n; j++) printf("%d ", 1);
        printf("\n");
        return 0;
      }
      if (book[m - 2] == 0) {
        printf("1 2");
        for (j = 3; j <= n; j++) printf(" %d", 1);
        printf("\n");
        return 0;
      }
      m -= 3;
      for (j = 1; j <= top && zhan[j] <= m; j++)
        if (book[m - zhan[j]] == 0) {
          x = zhan[j];
          y = m - zhan[j];
          break;
        }
      book2[3] = 3;
      for (j = n; j >= 1; j--)
        if (j != 3) {
          if (x >= j) {
            book2[j] = 1;
            x -= j;
          } else
            book2[j] = 2;
        }
    } else {
      for (j = 1; j <= top && zhan[j] <= m; j++)
        if (book[m - zhan[j]] == 0) {
          x = zhan[j];
          y = m - zhan[j];
          break;
        }
      for (j = n; j >= 1; j--)
        if (x >= j) {
          book2[j] = 1;
          x -= j;
        } else
          book2[j] = 2;
    }
    for (j = 1; j <= n; j++) printf("%d ", book2[j]);
    printf("\n");
  }
  return 0;
}
