#946. Next permutation
You get a list. Print the next permutation in lexicographic order. If it is the last one, print the first one (sorted in increasing order).
### Input
The first line has n, the second line has n integers separated by spaces.
### Output
One line.
Examples
Input
1 2
Output
2
Input
6 5 1 3 6 5 2
Output
5 1 5 2 3 6
💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.