Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

A. Difference Row

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou want to arrange *n* integers *a*_{1}, *a*_{2}, ..., *a*_{n} in some order in a row. Let's define the value of an arrangement as the sum of differences between all pairs of adjacent integers.

More formally, let's denote some arrangement as a sequence of integers *x*_{1}, *x*_{2}, ..., *x*_{n}, where sequence *x* is a permutation of sequence *a*. The value of such an arrangement is (*x*_{1} - *x*_{2}) + (*x*_{2} - *x*_{3}) + ... + (*x*_{n - 1} - *x*_{n}).

Find the largest possible value of an arrangement. Then, output the lexicographically smallest sequence *x* that corresponds to an arrangement of the largest possible value.

Input

The first line of the input contains integer *n* (2 ≤ *n* ≤ 100). The second line contains *n* space-separated integers *a*_{1}, *a*_{2}, ..., *a*_{n} (|*a*_{i}| ≤ 1000).

Output

Print the required sequence *x*_{1}, *x*_{2}, ..., *x*_{n}. Sequence *x* should be the lexicographically smallest permutation of *a* that corresponds to an arrangement of the largest possible value.

Examples

Input

5

100 -100 50 0 -50

Output

100 -50 0 50 -100

Note

In the sample test case, the value of the output arrangement is (100 - ( - 50)) + (( - 50) - 0) + (0 - 50) + (50 - ( - 100)) = 200. No other arrangement has a larger value, and among all arrangements with the value of 200, the output arrangement is the lexicographically smallest one.

Sequence *x*_{1}, *x*_{2}, ... , *x*_{p} is lexicographically smaller than sequence *y*_{1}, *y*_{2}, ... , *y*_{p} if there exists an integer *r* (0 ≤ *r* < *p*) such that *x*_{1} = *y*_{1}, *x*_{2} = *y*_{2}, ... , *x*_{r} = *y*_{r} and *x*_{r + 1} < *y*_{r + 1}.

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Mar/19/2019 09:40:13 (d3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|