#d1201. 摘桃子
摘桃子
Picking Peaches
Problem Description
There are people picking peaches in an orchard. The people stand in a line, and from left to right the number of peaches each person has is .
The orchard has a free-peach rule: if the total number of peaches held by consecutive people, divided by , leaves a remainder exactly equal to , then those people can get peaches for free. Moreover, there is only one chance per day to get peaches for free.
Figure out how many different ways there are for someone to get peaches for free today.
Input Format
The first line contains two integers and .
The next line contains integers .
Output Format
One integer: the answer.
Sample Input
8 4
4 2 4 2 4 2 4 2
Sample Output
7
Sample Explanation
The seven different schemes are: ; ; ; ; ; ; .
Note: two schemes are different as long as at least one boundary of the contiguous segment differs.
Constraints
For all data, , , .