Gluttony

题意翻译

给定一个有 $n$ 个互不相同元素的数组 $a$,构造一个数组 $b$,满足: - $b$ 是 $a$ 的一个排列; - 选择任意一个下标的集合 $\{x_1, x_2, \cdots, x_k\}(1\le k<n)$,都满足 $\sum_{i=1}^k a_{x_i} \ne \sum_{i=1}^k b_{x_i}$。 如果不存在这样的 $b$,输出 $-1$。

题目描述

You are given an array $ a $ with $ n $ distinct integers. Construct an array $ b $ by permuting $ a $ such that for every non-empty subset of indices $ S={x_{1},x_{2},...,x_{k}} $ ( $ 1<=x_{i}<=n $ , $ 0&lt;k&lt;n $ ) the sums of elements on that positions in $ a $ and $ b $ are different, i. e. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF891B/3cd3fa1580a1bdd16185974adbd0425cf2d97136.png)

输入输出格式

输入格式


The first line contains one integer $ n $ ( $ 1<=n<=22 $ ) — the size of the array. The second line contains $ n $ space-separated distinct integers $ a_{1},a_{2},...,a_{n} $ ( $ 0<=a_{i}<=10^{9} $ ) — the elements of the array.

输出格式


If there is no such array $ b $ , print -1. Otherwise in the only line print $ n $ space-separated integers $ b_{1},b_{2},...,b_{n} $ . Note that $ b $ must be a permutation of $ a $ . If there are multiple answers, print any of them.

输入输出样例

输入样例 #1

2
1 2

输出样例 #1

2 1 

输入样例 #2

4
1000 100 10 1

输出样例 #2

100 1 1000 10

说明

An array $ x $ is a permutation of $ y $ , if we can shuffle elements of $ y $ such that it will coincide with $ x $ . Note that the empty subset and the subset containing all indices are not counted.