406433: GYM102409 E Googles wants to maximize
Description
Diego and Googles are playing a game, in this game there are exactly $$$2*N$$$ numbers laid out around a circle such that for every position $$$i$$$, the numbers with positions $$$i+1 \mod 2*N$$$ and $$$i-1 \mod 2*N$$$ are beside it.
In this game first is Diego's turn, he will grab exactly $$$N$$$ consecutive numbers and then is Googles' turn, he will grab the remaining $$$N$$$ numbers. Then both of them sum all the numbers they grabbed and whoever has the biggest number will win. Googles immediately realized that if Diego plays perfectly there is no way for Googles to win, in the best case scenario they can tie. Therefore Googles asked Diego if he can reorder the numbers however he wants before Diego's turn, and he agreed.
Now, given $$$2*N$$$ numbers, what you have to do is find a permutation such that if Diego plays perfectly Googles can obtain the maximum amount of points possible.
InputAn integer $$$N$$$ $$$(1 \le N \le 6)$$$, there are exactly $$$2*N$$$ numbers.
Followed by a line with $$$2*N$$$ positive integer numbers, each smaller or equal to 1 million.
Output$$$2*N$$$ numbers in a single line (separated by a single space), a permutation of the original $$$2*N$$$ numbers such that it doesn't matter what Diego does Googles' score is maximized. If there are several possible solutions, print any of them.
ExampleInput5 992 100 115 102 101 117 100 145 147 982Output
992 100 115 102 147 982 101 117 100 145Note
In the first case the maximum Diego can get given the permutation is $$$1456$$$ which means that Googles can get $$$1445$$$.