#D6395. Max Element
Max Element
Max Element
Write a program which manipulates a sequence by the following operations:
- min(): report the minimum element in
- max(): report the maximum element in
Constraints
Input
The input is given in the following format.
:
In the first line, (the number of elements in ) is given. In the second line, (each element in ) are given. In the third line, the number of queries is given and each query is given in the following lines. denotes a type of query. 0 and 1 represents min() and max() respectively.
Output
For each query, print the minimum element or the maximum element in a line.
Example
Input
7 8 3 7 1 9 1 4 3 0 0 3 0 1 5 1 0 7
Output
3 1 9
inputFormat
Input
The input is given in the following format.
:
In the first line, (the number of elements in ) is given. In the second line, (each element in ) are given. In the third line, the number of queries is given and each query is given in the following lines. denotes a type of query. 0 and 1 represents min() and max() respectively.
outputFormat
Output
For each query, print the minimum element or the maximum element in a line.
Example
Input
7 8 3 7 1 9 1 4 3 0 0 3 0 1 5 1 0 7
Output
3 1 9
样例
7
8 3 7 1 9 1 4
3
0 0 3
0 1 5
1 0 7
3
1
9
</p>