#P1168. Median of the First Odd Number of Elements
Median of the First Odd Number of Elements
Median of the First Odd Number of Elements
Given a sequence of non-negative integers \(A\) of length \(N\), you are required to compute the median of the first odd number of terms in \(A\). In other words, if \(N\) is odd, consider all \(N\) elements; if \(N\) is even, consider the first \(N-1\) elements. The median is defined as the middle element when the selected numbers are sorted in non-decreasing order.
inputFormat
The first line contains a single integer \(N\) representing the length of the sequence. The second line contains \(N\) non-negative integers separated by spaces, which constitute the sequence \(A\).
outputFormat
Output a single integer, the median of the considered subset of \(A\).
sample
5
3 1 2 5 4
3