403659: GYM101234 F Lonely Dreamoon 2

Memory Limit:0 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Lonely Dreamoon 2time limit per test1 secondmemory limit per test512 mebibytesinputstandard inputoutputstandard output

Dreamoon, who doesn't have a girlfriend, often goes for a walk along some streets in Taipei while thinking about problems from algorithm competitions. Unfortunately, there are so many couples acting lovey-dovey on the street that Dreamoon can not focus on thinking about those problems.

One day, despite the love birds everywhere, Dreamoon discovered a problem input containing an integer sequence: a1, a2, a3, ..., aN.

Dreamoon thought: because I'm single, every pair of consecutive numbers should have a large difference! This is, Dreamoon wants to reorder the sequence to make the value as large as possible.

So Dreamoon turned on Drazil, who does have a girlfriend, and forced Drazil to fulfill the above condition by reordering the integer sequence. Please help poor Drazil  > _ < 

Input

The input consists of two lines. The first line contains an integer N. The second line consists of N integers a1, a2, ..., aN.

  • 2 ≤ N ≤ 2 × 105
  •  - 109 ≤ ai ≤ 109
Output

Output a single line consisting of N integers, denoting the integer sequence a after reordering. For this reordering, the value must be the largest possible among all reorderings of the input sequence. If there are several possible answers, output any one of them.

ExamplesInput
3
3 1 5
Output
3 5 1
Input
4
-1 -1 1 1
Output
1 -1 1 -1

加入题单

算法标签: