Mr.Jordan Belfort is a renowned stock broker who owns the Stock Brokerage firm,Starton Oakmount at Wall Street. He does a lot of "legal" things and one among them is selling penny stocks to big people(50% commission!). Kasab, the renowned computer hacker does not like what Mr.Belfort is doing. So Kasab decides to break into the Straton Oakmount's network and modify their brokerage transactions.
By sniffing their data transactions Kasab found their process of selling penny stocks.
Kasab, after learning this process decides to break it. If he stops all transactions , firm might detect the intrusion and shutdown their network for maintenance. So his attack must be silent and also cause damage to the firm.
The attack planned by Kasab was, after invading their network, he likes to modify the algorithm which chooses the maximum of the sub-list to another algorithm which chooses the minimum of the sub-list so that it does significant damage to the firm's profit silently.
Kasab is busy planning the intrusion, detecting exploits on network and planning the attack. Meanwhile you are given the job of programming the alternate algorithm.
Given a list and the indices of the sub-list return the minimum of the sub-list.
Input consists of N on the first line, the total number of penny stocks in the list. On the next line, N space separated integers , where each integer represent the buying price of the stock. Next line has an integer M, the total number of client's sub-lists. Then M lines of input follow, each line contains two space separated integers, the starting index and the ending index of the list.
Output an integer in new line for each of the client's sub-list which will be the minimum of the buying prices in the given sub-list.
1 <= N <= 1000
1 <= Each stock's price <= 1000000
1 <= M <= 1000
NOTE: Only submissions in C-Language will be accepted.
The sample case has 6 stock prices which are listed as [4,5,8,7,4,6]. Then it has 3 client requests. First request is from 1 to 6 thus the sub-list is [4,5,8,7,4,6] The minimum of the sub-list is printed as 4. In next request the sub-list is [8,7], the minimum is 7. Last request's sub-list is [4,5,8,7,4], the minimum is printed as 4.