Each Tarotian has a charisma value $a_i$. The Lover value of a line of $n$ ($n \ge 2$) Tarotians (represented by an array $a$), is defined as $$L(a) = \sum_{i=1}^{n-1}{a_i a_{i+1}}$$ For example, $$L([3, 5, 4, 6]) = a_1 a_2 + a_2 a_3 + a_3 a_4 = 15 + 20 + 24 = 59$$ You are given a number $A$, the well-known optimal Lover value. Determine the number of sub-lines of Tarotians of Lover value $A$ in a given line of Tarotians. In other words, determine the number of subarrays of Lover value $A$ within the given array. Two sub-lines are considered different if they either start or end at a different point.
Input
The first line consists of two integers $N, A$. The second line consists of $N$ integers $a_i$.
Output
Output an integer.
Constraints
For all testcases: $1 \le N \le 10^6$, $-10^5 \le a_i \le 10^5$, $-10^{16} \le A \le 10^{16}$
Subtask 1 (5%): $N \le 10^3$
Subtask 2 (95%): No other constraints
Sample Test Cases
Input | Output | |
---|---|---|
5 69 0 10 8 -1 3 |
2 | |
$L([10, 8, -1, 3]) = 69$, $L([0, 10, 8, -1, 3]) = 69$. |
Scoring: Per Subtask
Authored by s17f18
Appeared in 2024 Mini Contest 3