Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/saralash-mediana

Median

Easy 1000 ms 128 MB 24%
Share

An odd number $n$ of integers is given. Find their median: the number that stands exactly in the middle when the numbers are sorted in increasing order.

The numbers sorted, the middle one highlighted

Input

The first line contains an odd positive integer $n$. The second line contains $n$ integers $a_{i}$ separated by spaces.

Output

One integer — the median.

Note

$1 \le n \lt 2 * 10^{5}$, $n$ is odd
$-10^{9} \le a_{i} \le 10^{9}$

Examples

Input #1
5
7 1 9 3 5
Output #1
5
Input #2
1
-4
Output #2
-4

Sign in to submit a solution

Signing up is free and takes a minute.