~/algor $ cat problems/massiv-min-va-max-almashtirish
Swap the smallest and the largest
Easy
1000 ms
128 MB
32%
A positive integer $n$ and an array of $n$ distinct integers are given. Swap the smallest and the largest elements of the array and print the array.
Input
The first line contains a positive integer $n$. The second line contains $n$ integers separated by spaces.
Output
One line with $n$ integers separated by spaces.
Note
$2 \le n \le 1000$
$-10^{9} \le a_{i} \le 10^{9}$
All numbers $a_{i}$ are distinct.
Examples
Input #1
5 15 3 42 99 27
Output #1
15 99 42 3 27
Input #2
3 10 50 30
Output #2
50 10 30