Xorin was recently elected president in his country and he wants to make travelling from one place to another great again.

His country is rather peculiar, it is composed of ** N** towns placed on a straight line, with a

**road connecting any**

`bidirectional`**adjacent ones.**

`2` The problem is that not all towns benefit from having a gas station, so travelers must plan in advance for the trip. Each traveler has a car with a given fuel capacity of ** C** litres and any drive to an adjacent town consumes

**litre of fuel.**

`1` When they get to a town which has a gas station, they can fill up the tank to the ` maximum capacity`. Xorin noticed that some people were forced to take the bus because their tank was not large enough for some distances. So he decided that he was going to serve any request coming from the people for gas station construction in additional towns, as long as the proposal consists of a minimal number of gas stations being built.

Xorin's advisor took note of this situation and decided to help the people by telling them what is the minimal number of gas stations that need to be built, starting with the initial configuration, so as to make their trip possible. He now receives a lot of requests of the form ** A B C**, meaning that the traveler wants to get from

`to`

**town A****with a tank of**

`town B``.`

**capacity C****The tank is full when the travelers start their journey.**

### Input

On the first line there is the number of towns ** N**.

On the second line there is an array of

**binary digits, without any spaces, where digit**

`N`**is**

`i`**if town**

`1`**has a gas station and**

`i`**otherwise.**

`0`On the third line there will be an integer

**, representing the number of requests as described above.**

`Q`The next

`lines contain the requests, in the form of`

**Q****integers**

`3`**each, separated by spaces.**

`A, B, C`### Output

** Q** lines, on line

**being the answer to request**

`i`**, representing the minimal number of gas stations that need to be built in order to make the trip of traveler**

`i`**possible.**

`i`### Restrictions

`1 ≤ N, Q ≤ 10`^{5}`1 ≤ C ≤ N``1 ≤ A ≤ B ≤ N`**Xorin doesn't actually build gas stations for a traveler**

### Sample

Input | Output | Explanation |
---|---|---|

70110001 3 1 5 1 1 7 5 1 4 2 | 10 0 | The first traveler wants to go from In order to arrive at the 5 The second traveler could use the following stategy: Travel from 1 to 3, refuel and drive all the way from 3 to 7 (by consuming 4 litres). |

It can be observed that the queries can be divided in two categories. Those smaller than `sqrt(n)`(square root of n) and those bigger.

For the queries bigger than `sqrt(n)` the solution is simple. Go through the segments of `0's` with length > `sqrt(n)` and calculate how many gas stations have to be built. The formula is `length / capacity` for full segments between `A` and `B` and almost identical for the suffix after `A` and prefix before `B`. The complexity for a query is `O(sqrt(n))` because you can't have more segments of this type.

For queries smaller than `sqrt(n)` the formula is the same, but we have too many segments, so we have to do preprocessing to answer fast.

We can build an array `L` where `L[i] = the length of i'th segment of 0's` and `Sum` where `Sum[i][j] = sum(L[x] / j) `with `x <= i` and `j <= sqrt(n)`. The preprocessing takes `O(n*sqrt(n))`. After these computations, we can see that for a query we need the range of full segments of `0's` between A and B, this is also a simple precomputation. The query can be now answered in `O(1)` .

!Also the memory can be optimised from `O(n*sqrt(n))` to `O(n)` by sorting the queries increasingly by capacity. But this wasn't a requirement for full score.