Skip to main content
LIVE CONTEST: Round #7 · Begin Marathon is live now! …

~/algor $ cat problems/array/swap-the-smallest-and-the-largest

Swap the smallest and the largest

Author Iqbolshoh Ilhomjonov 3 @iqbolshoh 650 problems
Easy 1000 ms 128 MB 32%
Share

A positive integer and an array of distinct integers are given. Swap the smallest and the largest elements of the array and print the array.

Swapping the smallest and the largest elements of an array

Input

The first line contains a positive integer . The second line contains integers separated by spaces.

Output

One line with integers separated by spaces.

Note



All numbers 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

Sign in to submit a solution

Signing up is free and takes a minute.