A student of z-school found a kind of sorting called z-sort. The array a with n elements are z-sorted if two conditions hold:

  1. ai ≥ ai - 1 for all even i, 
  2. ai ≤ ai - 1 for all odd i > 1. 



For example the arrays [1,2,1,2] and [1,1,1,1] are z-sorted while the array [1,2,3,4] isn’t z-sorted.

Can you make the array z-sorted?

Input

The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array a.

The second line contains n integers ai (1 ≤ ai ≤ 109) — the elements of the array a.

Output

If it's possible to make the array a z-sorted print n space separated integers ai — the elements after z-sort. Otherwise print the only word "Impossible".

Examples

Input

4
1 2 2 1


Output

1 2 1 2


Input

5
1 3 2 2 5


Output

1 5 2 3 2
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Main {

    private static final double EPS = 1e-9;

    public static void main(String[] args) throws Exception {
        FastScanner fastScanner = new FastScanner(System.in);
        PrintWriter printWriter = new PrintWriter(System.out);
        Main main = new Main();
        main.solveB(fastScanner, printWriter);
        printWriter.close();

    }

    public void solveA(FastScanner scanner, PrintWriter writer) {
        int h1 = scanner.nextInt();
        int h2 = scanner.nextInt();

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        h1 = h1 + a * 8;
        if ((h1 < h2) && (b >= a)) {
            writer.printf("-1\n");
            return;
        }

        int need = h2 - h1;
        if (need < 0) need = 0;
        int ans = (int) Math.ceil(need * 1.0 / ((a - b) * 12));
        writer.printf("%d\n", ans);
    }

    public void solveB(FastScanner scanner, PrintWriter writer) {
        int n = scanner.nextInt();
        int[] origNums = new int[n];
        for (int i = 0; i < n; i++) origNums[i] = scanner.nextInt();
        Arrays.sort(origNums);
        int mid = (origNums.length + 1) / 2;
        int nums[] = new int[n];
        int leftPos = 0;
        int rightPos = mid;
        for (int i = 0; i < n; i += 2) {
            nums[i] = origNums[leftPos++];
            if (rightPos < n)
                nums[i + 1] = origNums[rightPos++];
        }

        boolean flag = false;
        for (int i = 0; i < n; i++) {
            if (flag) writer.printf(" ");
            writer.printf("%d", nums[i]);
            flag = true;
        }
        writer.println();
    }

    static class Pair<U, V> {
        U x;
        V y;

        public Pair(U x, V y) {
            this.x = x;
            this.y = y;
        }
    }

    static class Point {
        long x, y;

        public Point(long x, long y) {
            this.x = x;
            this.y = y;
        }
    }

    long twoTimesAreaOfTriangle(Point a, Point b, Point c) {
        long ar = a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y);
        if (ar < 0) ar = ar * (-1);
        return ar;
    }

    boolean isCisOnAB(Point a, Point b, Point c) {
        long cross = (c.y - a.y) * (b.x - a.x) - (c.x - a.x) * (b.y - a.y);
        if (cross != 0) return false;
        long dotproduct = (c.x - a.x) * (b.x - a.x) + (c.y - a.y) * (b.y - a.y);
        if (dotproduct < 0)
            return false;
        long squaredlengthba = (b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y);
        if (dotproduct > squaredlengthba) return false;

        return true;

    }


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                    return next();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }


}