Problem:
Score : 600 points

Problem Statement

Nagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers.

She thinks that a set S = \{a_{1}, a_{2}, ..., a_{N}\} of distinct positive integers is called special if for all 1 \leq i \leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is not 1.

Nagase wants to find a special set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a special set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000.

Constraints

3 \leq N \leq 20000

Input

Input is given from Standard Input in the following format:

N

Output

Output N space-separated integers, denoting the elements of the set S. S must satisfy the following conditions :

The elements must be distinct positive integers not exceeding 30000.

The gcd of all elements of S is 1, i.e. there does not exist an integer d > 1 that divides all elements of S.

S is a special set.

If there are multiple solutions, you may output any of them. The elements of S may be printed in any order. It is guaranteed that at least one solution exist under the given contraints.

Sample Input 1

3

Sample Output 1

2 5 63

\{2, 5, 63\} is special because gcd(2, 5 + 63) = 2, gcd(5, 2 + 63) = 5, gcd(63, 2 + 5) = 7. Also, gcd(2, 5, 63) = 1. Thus, this set satisfies all the criteria.

Note that \{2, 4, 6\} is not a valid solution because gcd(2, 4, 6) = 2 > 1.

Sample Input 2

4

Sample Output 2

2 5 20 63

\{2, 5, 20, 63\} is special because gcd(2, 5 + 20 + 63) = 2, gcd(5, 2 + 20 + 63) = 5, gcd(20, 2 + 5 + 63) = 10, gcd(63, 2 + 5 + 20) = 9. Also, gcd(2, 5, 20, 63) = 1. Thus, this set satisfies all the criteria.

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

#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define ff first
#define ss second
typedef long long ll;
#define dforn(i, n) for(int i = n - 1; i >= 0; i--)

const int MAXN = 30000;

int n;
//~ vector<int> V = {2,3,55,72,66,12,60,90,36,54,30,48,42,24,6,126,144,180,150,186,198,132,174,156,114,18,192,120,84,96,102,138,270,252,78,240,276,294,210,222,264,234,162,108,288,282,246,204,300,390,228,312,330,216,324,360,306,354,372,378,348,342,318,396,336,258,402,480,438,492,432,462,486,420,414,426,366,474,450,2442,1758,2490,1650,1980,1410,1590,672,1728,510,2316,2184,780,840,2994,1356,540,2394,1026,1020,2040,930,2850,2958,612,900,1470,1170,2670,966,2904,2520,1440,2280,1320,1290,2610,660,720,1890,1710,2190,2250,2940,2844,1452,1824,2334,2736,2010,2580,2790,1698,2142,1770,1368,1848,2154,1212,1218,2220,2340,888,972,1668,2022,1620,2034,1836,1740,978,1032,1080,1122,2706,2322,2910,630,1662,792,2616,618,2682,1920,546,2640,1944,570,654,2256,1530,2820,1200,1632,2748,2928,2892,408,1542,960,864,2046,2880,2400,2700,1854,1506,1992,2388,1950,2328,2838,594,1110,1260,2448,2952,750,870,2310,642,1878,2016,774,1680,1968,858,2376,1056,1254,1716,2232,3000,1038,1932,2370,2070,1482,1128,1446,1794,648,2772,2430,1050,2262,948,1500,2304,1776,1380,804,2586,2160,1524,2286,810,666,1188,2796,2946,2244,1914,924,2712,2832,2988,1236,1734,2550,2778,1842,1800,1560,1068,912,1830,990,2760,1428,882,1098,1782,1584,1518,2688,1272,1788,2964,2556,2130,528,822,2808,2982,1350,2466,1674,1692,1938,1626,2214,1086,2784,1230,1134,2886,1074,2646,786,2934,2874,1596,2562,2112,1176,606,2724,2028,2052,2238,762,2970,954,1116,1722,1638,2460,1182,2118,2634,1896,2100,558,1962,1866,894,2406,2694,1464,996,1860,708,1092,1416,2664,768,2742,1812,2628,1266,1434,690,1902,2208,1422,168,1548,2352,2730,1140,906,2508,2178,1458,1578,2802,600,2538,2574,2598,636,2004,1362,1248,1194,2526,2358,2082,1152,2148,2604,756,1752,798,1974,2766,2382,1278,504,1926,1572,1158,624,2196,1764,1296,1344,2106,1326,726,1908,2976,2544,1746,1554,2274,1986,522,2718,384,1806,2484,846,2454,2166,1002,588,1656,1284,2676,1044,2652,1386,1392,1512,2568,2514,456,534,2496,738,942,576,834,1608,1242,2124,1146,2418,2172,1062,1308,2916,1644,468,2532,1164,1206,444,2826,936,714,1332,1008,2292,1398,1704,816,2088,2202,2814,1686,2472,678,2424,2436,732,2298,2058,852};
vector<int> V = {2, 3, 4, 9}, sub;

bool ok(){
    int s = accumulate(V.begin(), V.end(), 0);
    int cnt = 0;
    //~ printf("la suma da %d :: %d %d %d\n", s, s % 2, s % 3, s % 6);
    forn(i, V.size()){
        if(__gcd(V[i], s - V[i]) == 1){
            //~ printf("-> gcd(%d, %d) == 1\n", V[i], s - V[i]);
            cnt++;
            //~ return false;
        }
    }
    //~ printf("DIO %d fallidos\n", cnt);
    return true;
}

int main() {
    scanf("%d", &n);
    if(n == 3){
        printf("%d %d %d\n", 2, 5, 63);
        return 0;
    }
    if(n == 4){
        printf("%d %d %d %d\n", 2, 5, 20, 63);
        return 0;
    }
    
    int modcnt = 0;
    for(int i = 6; i <= MAXN; i += 2){
        if(i % 6 == 0) continue;
        sub.pb(i); modcnt += i % 6; modcnt %= 6;
        if(modcnt == 0){
            if((int)V.size() + (int)sub.size() > n) break;
            while(sub.size()){
                V.pb(sub.back());
                sub.pop_back();
            }
        }
    }
    
    sub.clear();
    for(int i = 12; i <= MAXN; i += 3){
        if(i % 6 == 0) continue;
        sub.pb(i);
        if(sub.size() == 2){
            if((int)V.size() + (int)sub.size() > n) break;
            while(sub.size()){
                V.pb(sub.back());
                sub.pop_back();
            }
        }
    }
    
    int last = 6;
    while((int)V.size() < n) V.pb(last), last += 6;
    
    sort(V.begin(), V.end());
    //~ printf("%d con %d\n", ok(), (int)V.size());
    forn(i, V.size()){
        if(i) printf(" ");
        printf("%d", V[i]);
    }
    puts("");
    return 0;
}