#arc101b. [arc101_b]Median of Medians
[arc101_b]Median of Medians
Problem Statement
We will define the median of a sequence of length , as follows:
- Let be the sequence obtained by sorting in non-decreasing order. Then, the value of the -th element of is the median of . Here, is integer division, rounding down.
For example, the median of is ; the median of is ; the median of is .
Snuke comes up with the following problem.
You are given a sequence of length . For each pair (), let be the median of the contiguous subsequence of . We will list for all pairs to create a new sequence . Find the median of .
Constraints
- is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the median of .
Sample Input 1
3
10 30 20
Sample Output 1
30
The median of each contiguous subsequence of is as follows:
- The median of is .
- The median of is .
- The median of is .
- The median of is .
- The median of is .
- The median of is .
Thus, and the median of is .
Sample Input 2
1
10
Sample Output 2
10
Sample Input 3
10
5 9 5 9 8 9 3 5 4 3
Sample Output 3
8