Олимпиадный тренинг

Задача 1874. Inversion between two elements


Given a one-dimensional array of dimension N (2 <= N <= 20). Invert elements that are between the maximum and minimum values ​​(the maximum and minimum values ​​should remain in their places).

Input
The first line contains the number N - the number of array elements. The second line contains the values ​​of the array elements.

Imprint
You need to display the resulting array.

 
Examples
# Input Output
1 4
1 2 3 4
1 3 2 4