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 < k < n) the sums of elements on that positions in a and b are different, i. e. $\sum_{i = 1}^{k} a_{x_{i}} \neq \sum_{i = 1}^{k} b_{x_{i}}$


-----Input-----

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.


-----Output-----

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.


-----Examples-----
Input
2
1 2

Output
2 1 

Input
4
1000 100 10 1

Output
100 1 1000 10



-----Note-----

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.

Difficulty: competition

Starter code:

Solutions:
n, a = int(input()), [int(i) for i in input().split()]
b, m = a[:], dict()
b.sort()
for i in range(len(b) - 1):
    m[b[i]] = b[i + 1]
m[b[-1]] = b[0]
for i in range(len(a)):
    a[i] = m[a[i]]
if len(set(b)) == n:
    print(*a)
else:
    print(-1)


n=int(input())
a=list(map(int,input().split()))
b=sorted(a)+[min(a)]
for i in range(n):
    a[i]=str(b[b.index(a[i])+1])
print(' '.join(a))



def solve():
    n=int(input())
    a=list(map(int,input().split()))
    b=sorted(a)+[min(a)]
    for i in range(n):
        a[i]=str(b[b.index(a[i])+1])
    print(' '.join(a))
    return
solve()


n=int(input())

a=list(map(int,input().split()))
b=a.copy()
a.sort()
c=[]
for i in range(n):
    c.append(a[(a.index(b[i])+1)%n])
print(*c)




n = int(input())
data = list(map(int, input().split()))

sorted_data = sorted(data)

ans = {}
for i in range(0, n):
    ans[sorted_data[i]] = sorted_data[(i + 1) % n]

for v in data:
    print(ans[v], end=' ')



import sys
input()
a = list(map(int, input().split()))
b = sorted(a)
for i in a:
	sys.stdout.write(str(b[b.index(i)-1]))
	sys.stdout.write(" ")
sys.stdout.write("\n")

n=int(input())
a=list(map(int,input().split()))
b = sorted(a) + [min(a)]
for i in range(n):print(b[b.index(a[i])+1],end=' ')


n, a = int(input()), list(map(int, input().split()))
b = sorted(a) + [min(a)]
print(' '.join([str(b[b.index(a[i]) + 1]) for i in range(n)]))

n = int(input())
L = list(map(int, input().split()))
S = sorted(L)
for i in L:
    print(S[(S.index(i) + 1)%n], end=' ')

n = int(input())
l = [int(i) for i in input().split(" ")]
index = []
nums = sorted(l)
for i in l:
    index.append(nums.index(i))
#print(index)
indexbis = [int(i - 1) for i in index]

for i in range(n):
    if indexbis[i] == min(indexbis):
        indexbis[i] = n - 1
        break
#print(indexbis)
for i in indexbis:
    print(l[index.index(i)], end = " ")





inf = lambda : map(int, input().split())
n, = inf()
a = list(inf())
p = sorted([i for i in range(n)], key=lambda x : a[x])
b = [0]*n
for i in range(n):
	b[p[i]] = a[p[(i+1)%n]]
for i in range(n):
	print(b[i], end=' ')
print()


n = int(input())
A = [int(a) for a in input().split(' ')]
R = sorted(A)

for i in range(n):
    if A[i] == R[-1]:
        A[i] = R[0]
    else:
        A[i] = R[R.index(A[i])+1]

print(' '.join([str(a) for a in A]))

n = int(input())
A = list(map(int, input().split()))
B = sorted(A)
for i in A:
    print(B[B.index(i) - 1], end=' ')

n  = int(input())
a  = list(map(int, input().split()))

def solve(n, a):
    if n == 1:
        return [str(a[0])]
    
    arr = [[x, i] for i, x in enumerate(a)]
    arr = sorted(arr, key=lambda x:x[0])
    ans = [-1] * n
    
    for [x, i], [y, j] in zip(arr[1:], arr[:-1]):
        ans[j] = str(x)
        
    ans[arr[-1][1]] = str(arr[0][0])
    
    return ans

ans = solve(n, a)

print(' '.join(ans))