Problems > Lower Median

Lower Median

Difficulty: 1000 3000 ms 128 MB

sorting

Print the lower median: the element at position ⌈N/2⌉ when the values are sorted (1-based).

Input: the first line has N; the second line has N integers.

Output: the lower median.

Constraints:

  • 1 ≤ N ≤ 105
  • −109 ≤ ai ≤ 109

Sample Tests

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

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.