Roxy, the space traveler, is facing a very abstract problem. Since she’s clueless as to how to solve it, you, as her best friend, have no choice but to help her out:
She is given an array c_1,c_2,…,c_N consisting of N integers, and Q pairs of endpoints (L_i,R_i), each representing the subarray c_L_i,c_L_i+1,…,c_R_i, where 1≤i≤N.
For each such pair (L_i,R_i), Roxy is asked what is the maximum number of disjoint sum-0 subarrays one can choose from the queried array c_L_i,c_L_i+1,…,c_R_i. Two subarrays are considered disjoint if they have no entries in common; however, they can still have neighboring endpoints. Note that, there might be entries from the queried array that are not part of any of the chosen subarrays.
The first line of the input contains a single integer N.
The second line contains N space-separated integers c_1,c_2,…,c_N.
The third line contains the number Q of queries.
The next Q lines contain two numbers L_i and R_i each, representing the ith query.
Print Q lines: on the ith line you should print the answer to the ith query.