Bored of studying physics, Fumino decides to take a break with a brainteaser!
Nariyuki gave her a permutation of the first
Nariyuki challenges her to get the lexicographically-smallest list. This is, of course, much too easy. Thus, Nariyuki allows her to perform at most one swap.
Suddenly the problem is much too hard for Fumino! She comes to you, Rizu, for help since you are good at such puzzles. Can you help her?
Definition: An array
Constraints
All
Subtask 1 [10%]
Subtask 2 [50%]
Subtask 3 [40%]
No additional constraints.
Input Specification
The first line contains
The next line contains
Output Specification
Output the lexicographically smallest array that can be created according to the puzzle's rules.
Sample Input
6
2 4 3 1 6 5
Sample Output
1 2 4 3 5 6
Explanation
Swapping the 1 2 4 3 5 6
, which can be proven to be the lexicographically smallest output.
Comments