CF1252A.Copying Homework

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Copying Homework

Danang and Darto are classmates. They are given homework to create a permutation of NN integers from 11 to NN. Danang has completed the homework and created a permutation AA of NN integers. Darto wants to copy Danang's homework, but Danang asks Darto to change it up a bit so it does not look obvious that Darto copied.

The difference of two permutations of NN integers AA and BB, denoted by diff(A,B)diff(A, B), is the sum of the absolute difference of AiA_i and BiB_i for all ii. In other words, diff(A,B)=Σi=1NAiBidiff(A, B) = \Sigma_{i=1}^N |A_i - B_i|. Darto would like to create a permutation of NN integers that maximizes its difference with AA. Formally, he wants to find a permutation of NN integers BmaxB_{max} such that diff(A,Bmax)diff(A,B)diff(A, B_{max}) \ge diff(A, B') for all permutation of NN integers BB'.

Darto needs your help! Since the teacher giving the homework is lenient, any permutation of NN integers BB is considered different with AA if the difference of AA and BB is at least NN. Therefore, you are allowed to return any permutation of NN integers BB such that diff(A,B)Ndiff(A, B) \ge N.

Of course, you can still return BmaxB_{max} if you want, since it can be proven that diff(A,Bmax)Ndiff(A, B_{max}) \ge N for any permutation AA and N>1N \gt 1. This also proves that there exists a solution for any permutation of NN integers AA. If there is more than one valid solution, you can output any of them.

Input

Input begins with a line containing an integer: NN (2N1000002 \le N \le 100\,000) representing the size of Danang's permutation. The next line contains NN integers: AiA_i (1AiN1 \le A_i \le N) representing Danang's permutation. It is guaranteed that all elements in AA are distinct.

Output

Output in a line NN integers (each separated by a single space) representing the permutation of NN integers BB such that diff(A,B)Ndiff(A, B) \ge N. As a reminder, all elements in the permutation must be between 11 to NN and distinct.

Note

Explanation for the sample input/output #1

With A=[1,3,2,4]A = [1, 3, 2, 4] and B=[4,2,3,1]B = [4, 2, 3, 1], $diff(A, B) = |1 - 4| + |3 - 2| + |2 - 3| + |4 - 1| = 3 + 1 + 1 + 3 = 8$. Since 848 \ge 4, [4,2,3,1][4, 2, 3, 1] is one of the valid output for this sample.

Samples

4
1 3 2 4
4 2 3 1
2
2 1
1 2

在线编程 IDE

建议全屏模式获得最佳体验