You are given a sequence of integers a_1, a_2, \ldots, a_n. A query Q(x, y) asks for the maximum sum of a contiguous subsegment lying within the segment :
Answer such queries.
The first line contains an integer n~(1 \le n \le 50000) — the length of the sequence.
The second line contains integers a_1, a_2, \ldots, a_n~(|a_i| \le 15007).
The third line contains an integer — the number of queries.
Each of the next lines contains two integers and y~(1 \le x \le y \le n) — the boundaries of a query.
For each query, print the value of Q(x, y) on a separate line.
Example 1