cho.sh
Notes
Loading...

Sum of Numbers 2

Time limit

0.5s

Memory limit

128 MB

Problem

You are given a sequence A[1], A[2], ..., A[N] of N positive integers. Count the number of pairs (i, j) such that the sum of the contiguous segment A[i], A[i+1], ..., A[j] is exactly M.

Input

The first line contains N (1 <= N <= 10,000) and M (1 <= M <= 300,000,000). The second line contains A[1], A[2], ..., A[N], separated by spaces. Each A[x] is a positive integer not greater than 30,000.

Output

Print the number of contiguous segments whose sum is M.