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# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest
{
    class Writer : IDisposable
    {
        private System.IO.TextWriter writer;
        private StringBuilder sb;
        private bool isReactive;
        public Writer(string path)
            : this(new System.IO.StreamWriter(path))
        {
        }
        public Writer(bool isReactive)
            : this(null, isReactive)
        {
        }
        public Writer(System.IO.TextWriter writer = null,
                        bool isReactive = false)
        {
            this.writer = (writer ?? Console.Out);
            this.isReactive = isReactive;
            if (!this.isReactive)
            {
                this.sb = new StringBuilder();
            }
        }
        public void Dispose()
        {
            if (!this.isReactive)
            {
                this.writer.Write(sb.ToString());
            }
            if (!this.writer.Equals(Console.Out))
            {
                this.writer.Dispose();
            }
        }
        public void Write(object val)
        {
            if (this.isReactive)
            {
                this.writer.Write(val.ToString());
                this.writer.Flush();
            }
            else
            {
                this.sb.Append(val.ToString());
            }
        }
        public void Write(string format, params object[] vals)
        {
            if (this.isReactive)
            {
                this.writer.Write(format, vals);
                this.writer.Flush();
            }
            else
            {
                this.sb.AppendFormat(format, vals);
            }
        }
        public void WriteLine(object val = null)
        {
            this.Write((val ?? string.Empty).ToString() + System.Environment.NewLine);
        }
        public void WriteLine(int val)
        {
            this.WriteLine(val.ToString());
        }
        public void WriteLine(long val)
        {
            this.WriteLine(val.ToString());
        }
        public void WriteLine(string val)
        {
            this.WriteLine((object)val);
        }
        public void WriteLine(string format, params object[] vals)
        {
            this.Write(format + System.Environment.NewLine, vals);
        }
    }

    class Scanner : IDisposable
    {
        private Queue<string> buffer;
        private char[] sep;
        private System.IO.TextReader reader;
        public Scanner(string path, char[] sep = null)
            : this(new System.IO.StreamReader(path), sep)
        {
        }
        public Scanner(System.IO.TextReader reader = null,
                        char[] sep = null)
        {
            this.buffer = new Queue<string>();
            this.sep = (sep ?? new char[] { ' ' });
            this.reader = (reader ?? Console.In);
        }
        private void CheckBuffer()
        {
            if (this.buffer.Count == 0 && this.reader.Peek() != -1)
            {
                string str = string.Empty;
                for (; string.IsNullOrEmpty(str);
                    str = this.reader.ReadLine()) ;

                str.Split(this.sep).ToList()
                   .ForEach(el => this.buffer.Enqueue(el));
            }
        }

        public void Dispose()
        {
            if (!this.reader.Equals(Console.In))
            {
                this.reader.Dispose();
            }
        }

        public string Next
        {
            get
            {
                this.CheckBuffer();
                return this.buffer.Dequeue();
            }
        }
        public string[] GetStringArray(int N)
        {
            return Enumerable.Range(0, N)
                             .Select(e => this.Next)
                             .ToArray();
        }

        public int NextInt
        {
            get
            {
                return int.Parse(this.Next);
            }
        }
        public int[] GetIntArray(int N)
        {
            return Enumerable.Range(0, N)
                             .Select(e => this.NextInt)
                             .ToArray();
        }

        public double NextDouble
        {
            get
            {
                return double.Parse(this.Next);
            }
        }
        public double[] GetdoubleArray(int N)
        {
            return Enumerable.Range(0, N)
                             .Select(e => this.NextDouble)
                             .ToArray();
        }

        public long NextLong
        {
            get
            {
                return long.Parse(this.Next);
            }
        }
        public long[] GetLongArray(int N)
        {
            return Enumerable.Range(0, N)
                             .Select(e => this.NextLong)
                             .ToArray();
        }

        public bool IsEnd
        {
            get
            {
                this.CheckBuffer();
                return this.buffer.Count == 0;
            }
        }
    }

    class MainClass : IDisposable
    {
        Scanner sc;
        Writer wr;
        const string backPath = "..";
        char dirSep = System.IO.Path.DirectorySeparatorChar;
        string inFilePath = string.Empty;
        string outFilePath = string.Empty;
        public MainClass()
        {
            this.inFilePath = MainClass.backPath
                            + this.dirSep
                            + MainClass.backPath
                            + this.dirSep
                            + "in.txt";
            this.outFilePath = MainClass.backPath
                             + this.dirSep
                             + MainClass.backPath
                             + this.dirSep
                             + "out.txt";

            this.wr = new Writer(this.IsReactive);
            //this.wr = new Writer(this.outFilePath);
#if DEBUG
            if (!this.IsReactive)
            {
                this.sc = new Scanner(this.inFilePath);
            }
            else
            {
                this.sc = new Scanner();
            }
#else
            this.sc = new Scanner();
#endif
        }
        static void Main(string[] args)
        {
            using (var mainClass = new MainClass())
            {
                mainClass.Solve();
            }
        }

        public void Dispose()
        {
            if (this.sc != null)
            {
                this.sc.Dispose();
                this.sc = null;
            }
            if (this.wr != null)
            {
                this.wr.Dispose();
                this.wr = null;
            }
#if DEBUG
            Console.WriteLine("続行するには何かキーを押してください...");
            Console.ReadKey();
#endif
        }

        void MakeTestCase()
        {
            var rand = new Random();
            if (this.wr != null)
            {
                this.wr.Dispose();
            }
            this.wr = new Writer(inFilePath);


        }

        int[] SieveOfEratosthenes(int maxVal)
        {
            List<int> ret = new List<int>();
            bool[] isPrime = new bool[maxVal + 1].Select(el => true).ToArray();
            isPrime[0] = isPrime[1] = false;
            for (int i = 2; i < maxVal + 1; i++)
            {
                if (isPrime[i])
                {
                    ret.Add(i);
                    for (int j = i * 2; j < maxVal + 1; j += i)
                    {
                        isPrime[j] = false;
                    }
                }
            }
            return ret.ToArray();
        }

        void Solve()
        {
            int N = sc.NextInt;
            var primes = SieveOfEratosthenes(55555 * 5);
            var primeSet = new HashSet<int>(primes);
            var ans = primes.Where(e => e % 10 == 1).ToArray();
            wr.WriteLine(string.Join(" ", Enumerable.Range(0, N).Select(e => ans[e])));
        }

        private bool IsReactive { get; } = false; // TODO: reactive check !!
    }
}