Your task is very simple, and even without big legend: you just need to find the maximum on a segment.
Initially the number of elements in array is given. The next line contains numbers — the initial array . Next line contains the number of queries . Each of the next lines contain two positive integers and — the segment, where you must find the maximum.
For each query print the maximum on a segment.