You are given an array $a$ of length $n$ and an integer $k.$ A subarray $b$ of length $m \le n$ is called good if and only if its alternating sum $\left( \displaystyle\sum_{i=1}^m (-1)^{i+1} \cdot b_i = b_1 - b_2 + b_3 - b_4 + \dots + (-1)^{m+1} \cdot b_m \right)$ equals $k.$ Count the number of good subarrays. A subarray is a sequence of consecutive elements of the array.
Input
The first line of the input consists of two integers, $n$ and $k$.
The second line of the input consists of $n$ integers, $a_1, a_2, \dots, a_n.$
Output
Print the answer in one line, the amount of subarrays whose sum is equal to $k.$.
Constraints
For all cases, $1 \le n \le 10^5, 0 \le k \le 10^5, 0 \le a_i \le 10.$
Sample Test Cases
Input | Output | |
---|---|---|
5 3 1 2 3 4 5 |
3 |
Scoring: Per Subtask
Authored by s17r28
Appeared in 2021 Mini Competition 0