You are given one permutation of the numbers from 1 to N. Write a program that finds the permutation that comes right after it in lexicographic order.
The first permutation in lexicographic order is the ascending one, and the last one is the descending one.
For N=3, the permutations in lexicographic order are:
The first line contains N. (1≤N≤10000)
The second line contains a permutation of the numbers from 1 to N, separated by spaces.
On the first line, print the permutation that comes right after the given one in lexicographic order, separated by spaces. If the given permutation is the last one in lexicographic order, print -1.