Median

You are given an array aa of nn elements. Furthermore, there are qq queries. Each query is of the form l r: What is the median element in the range [l,r][l,r]. In this case, we consider the median of an even length list the minimum of the two middle values.

Input Format

The first line is n q, the number of elements and queries. The next line contains the array a. The next q lines each contain two integers l r, a query.

Sample Input

Input 1
5 1
1 2 3 4 5
1 4

Sample Output

Output 1
3

Constraints

1≤n,q≤1e51 \le n,q \le 1e5 1≤a[i]≤1e41 \le a[i] \le 1e4

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.