e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Problems

Change max and min

Change max and min

Given array of n integers. Change all its maximum elements to minimum, and all its minimum elements change to maximum.

Input

First line contains number n (n100). Next line contains n integers, each of them does not exceed 100 by absolute value.

Output

Print the updated array.

Time limit 1 second
Memory limit 128 MiB
Input example #1
7
3 5 -7 7 5 -9 -4
Output example #1
3 5 -7 -9 5 7 -4