Problem:
Score: 400 points

Problem Statement

Print a sequence a_1, a_2, ..., a_N whose length is N that satisfies the following conditions:

a_i (1 \leq i \leq N) is a prime number at most 55 555.

The values of a_1, a_2, ..., a_N are all different.

In every choice of five different integers from a_1, a_2, ..., a_N, the sum of those integers is a composite number.

If there are multiple such sequences, printing any of them is accepted.

Notes

An integer N not less than 2 is called a prime number if it cannot be divided evenly by any integers except 1 and N, and called a composite number otherwise.

Constraints

N is an integer between 5 and 55 (inclusive).

Input

Input is given from Standard Input in the following format:

N

Output

Print N numbers a_1, a_2, a_3, ..., a_N in a line, with spaces in between.

Sample Input 1

5

Sample Output 1

3 5 7 11 31

Let us see if this output actually satisfies the conditions.

First, 3, 5, 7, 11 and 31 are all different, and all of them are prime numbers.

The only way to choose five among them is to choose all of them, whose sum is a_1+a_2+a_3+a_4+a_5=57, which is a composite number.

There are also other possible outputs, such as 2 3 5 7 13, 11 13 17 19 31 and 7 11 5 31 3.

Sample Input 2

6

Sample Output 2

2 3 5 7 11 13

2, 3, 5, 7, 11, 13 are all different prime numbers.

2+3+5+7+11=28 is a composite number.

2+3+5+7+13=30 is a composite number.

2+3+5+11+13=34 is a composite number.

2+3+7+11+13=36 is a composite number.

2+5+7+11+13=38 is a composite number.

3+5+7+11+13=39 is a composite number.

Thus, the sequence 2 3 5 7 11 13 satisfies the conditions.

Sample Input 3

8

Sample Output 3

2 5 7 13 19 37 67 79

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#include <set>
#include <random>
#include <sstream>
#include <stack>
#include <deque>

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
    int N;
    cin >> N;
    vi p_list;
    vi used(55556, 0);
    set<int> p_map;
    vi wa;
    int c = 0;
    REP(i,2,55556) {
        if (!used[i]) {
            p_list.push_back(i);
            p_map.insert(i);
            for (int j = 2; j*i <= 55555; j++) {
                used[j*i] = 1;
            }
            c++;
            if (c >= 5) {
                int s = 0;
                rep(j,5) s += p_list[c-5+j];
                wa.push_back(s);
            }
        }
    }
    
    vi ans = {54973, 54959, 54949, 54941, 54919};
    set<int> st1;
    set<int> st2;
    set<int> st3;
    set<int> st4;
    rep(i,5) {
        set<int> ng1 = {p_list[i]};
        set<int> ng2 = {};
        set<int> ng3 = {};
        st1.insert(p_list[i]);
        for (int a : st1) {
            if (ng1.count(a)) continue;
            //cout << a + p_list[i] << endl;
            ng2.insert(a + p_list[i]);
            st2.insert(a + p_list[i]);
        }
        for (int a : st2) {
            if (ng2.count(a)) continue;
            ng3.insert(a + p_list[i]);
            st3.insert(a + p_list[i]);
        }
        for (int a : st3) {
            if (ng3.count(a)) continue;
            st4.insert(a + p_list[i]);
        }
    }
    int n = 5;
    int i = p_list.size()-5;
    while (n < N) {
        int can = 1;
        for (int a : st4) {
            if (p_map.count(a + p_list[i])) {
                can = 0;
            }
        }
        if (can) {
                ans.push_back(p_list[i]);
                set<int> ng1 = {p_list[i]};
                set<int> ng2 = {};
                set<int> ng3 = {};
                st1.insert(p_list[i]);
                for (int a : st1) {
                    if (ng1.count(a)) continue;
                    ng2.insert(a + p_list[i]);
                    st2.insert(a + p_list[i]);
                }
                for (int a : st2) {
                    if (ng2.count(a)) continue;
                    ng3.insert(a + p_list[i]);
                    st3.insert(a + p_list[i]);
                }
                for (int a : st3) {
                    if (ng3.count(a)) continue;
                    st4.insert(a + p_list[i]);
                }
                n++;
            }
        i--;
    }
    for (int a : ans) cout << a << " ";
    cout << endl;
    // cout << ans << endl;
    return 0;
}