cho.sh
Notes
Loading...

Sum of Numbers 4

Time limit

2s

Memory limit

128 MB

Problem

An integer array A contains N integers A[1], A[2], ..., A[N]. For indices i and j satisfying 1 <= i <= j <= N, the sum of the contiguous elements from A[i] through A[j] is called a subarray sum.

Given N and the array A, write a program that counts how many of the N x (N + 1) / 2 possible subarray sums are equal to K.

Input

The first line contains two integers N and K. (1 <= N <= 200,000, |K| <= 2,000,000,000) There is one space between N and K.

The second line contains the N integers of array A, in the order A[1], A[2], ..., A[N], separated by spaces. The absolute value of each given integer does not exceed 10,000.

Output

Print the number of subarray sums equal to K on the first line.