D. Alternative Worlds II
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Do you believe in alternative worlds? A group of researchers has discovered an anomaly that may indicate the existence of parallel realities. To confirm or refute the theory, they need to solve the following problem:

You are given a multiset $$$a$$$ consisting of numbers $$$a_1, \cdots, a_n$$$. It is required to split it into some collection of non-empty multisets $$$S_1, \cdots, S_k$$$ so as to maximize the sum of their medians.

In other words, you need to choose the number of multisets $$$k$$$ and assign each element of the multiset $$$a$$$ to exactly one of the sets $$$S_1, \cdots, S_k$$$. Then you need to compute $$$x = med(S_1) + med(S_2) + \cdots + med(S_k)$$$.

As the answer, you need to find the maximum possible value of $$$x$$$.

In this problem, for a sorted set $$$S$$$ with elements $$$s_1, \cdots, s_m$$$ (arranged in increasing order), the median is defined as follows: $$$med(S) = (s_{\lceil \frac{n}{2} \rceil} + s_{\lceil \frac{n+1}{2} \rceil}) / 2$$$.

For example: $$$med(\{1, 5, 13\}) = 5$$$, $$$med(\{1, 5, 7, 13\}) = 6$$$.

Input

The first line of the input contains the number $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n\, (|a_i| \le 10^9)$$$ — the values of the elements of the multiset $$$a$$$.

Output

In the only line, print the answer to the problem, multiplied by $$$2$$$.

Examples
Input
2
-190 -94
Output
-284
Input
5
30 -5 1 -1 -10
Output
54