The 9 Axioms of the Universe
In a world where a conflict erupted between you and Evil Chmyaaax, there exist 9 Axioms that can explain everything (literally everything). The fact that there are exactly nine was proven long ago and is taught in schools, but not all Axioms are known, and not everyone can understand them. If one were to uncover them all, it would open the path to controlling the universe (in the most literal sense). Long ago, Chmyaaax...
Let's see what they study in schools there. Here's an example of a test question from 5th grade, can you solve it?
Let's call an array good if there does not exist a subsegment of it such that the sum of its elements equals 0. Formally: .
There is an array of length and queries to it. Each query is described by the numbers . It is necessary to solve the following problem for each query:
If we consider the subarray of array from to , what is the minimum number of elements that need to be changed so that this subarray becomes good?
Input
The first line contains two integers and — the length of array , and the number of queries.
The second line contains integers — the elements of the array .
The next lines contain a pair of integers — the parameters of the -th query.
Output
Output integers – the answer to each query.
Examples
Note
In the first query of the first sample, we need to solve the problem on the whole array : . There is a subsegment which has sum of zero, that is why we need to do at least one change to the array to make it good. If we make then array will be good.
In the third query of the second sample, we need to solve the problem on subarray . We can do two changes to make it which is a good array. It can be shown that it is a minimal number of operations to make the subarray good.
Scoring
( points): ;
( points): ;
( points): If is a segment with a sum of , then is also a segment with a sum of ;
( points): No two segments with a sum of intersect, more formally if and are two different segments with sum then or ;
( points): ;
( points): no additional constraints;