Bỏ qua đến nội dung

A. Median

Mã bài: icpchusc2025p1 Nhóm: Uncategorized Dạng bài: Undefined

Giới hạn thời gian
1,0 s
Giới hạn bộ nhớ
256 MB
Điểm
1một phần
Tỉ lệ AC
39,6%
Người giải
151

A median in an array with the length of n is an element which occupies position number \left\lfloor \frac{n+1}{2} \right\rfloor after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1).

We define an expression \left\lfloor \frac{a}{b} \right\rfloor as the integer part of dividing number a by number b.

Given an array a consists of n integers, determine the median of the array.

Input

  • The input starts with a positive integer t (1 \le t \le 10) — the number of test cases. Each test case consists of two lines:
  • The first line contains a positive integer n (1 \le n \le 5.10^4), which represents the number of elements in the array.
  • The second line contains n positive integers a_i (1 \le a_i \le 10^9), which are the elements of the array.

Output

  • For each test case, print a single line containing one integer, which is the median of the array.

Example

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

Bình luận