cswork / OAOpen practice workspace

AmazonOA #189

Find Security Level

Estimated MediumJudge-ready

Topics (AI-labelled)Prefix & RangesHashingTwo Pointers

Count the non-empty contiguous subarrays whose element sum, taken modulo k as a non-negative remainder, equals exactly the subarray length. Under the original numeric constraints elements may be equal, and identity does not affect the sum.

Input

The first line contains n k; the second line contains the elements. 1≤n≤200000; 1≤elements,k≤10^9.

Output

Output a single integer, the answer.

Example 1

Input:

4 4
1 3 2 4

Output:

2

Example 2

Input:

3 2
1 1 1

Output:

3

Example 3

Input:

1 1
1

Output:

0

Example notes

The answers are 2, 3 and 0.

Editorial

Loading solution…