Under construction

Still being built. Things may change

Number Selection Game

Time limit2sMemory limit128 MB

Summary
Given 2N-1 integers where N is a power of two, select exactly N of them whose sum is divisible by N, using a doubling construction.
Level

Hard8 of 10

Topics
Divide and conquer, Math, Combinatorics, Greedy
Solved
No attempts yet

Problem

You are given an integer NN such that N=2kN = 2^k and 1≤k≤101 \le k \le 10. Then 2N−12N - 1 integers are given.

Choose exactly NN of the given numbers so that the sum of the chosen numbers is divisible by NN. Print the chosen NN numbers. If several answers are possible, print any one of them.

Input

The first line contains NN.

The second line contains 2N−12N - 1 integers. Each integer is between 00 and 10001000, inclusive.

Output

On the first line, print NN numbers separated by spaces whose sum is divisible by NN.

If several answers are possible, print any one of them. If no such selection exists, print -1.

Examples1

  1. Example 1

    Input
    4
    1 2 3 4 5 6 7
    
    Expected output
    1 3 5 7