시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 555 MB521100.000%

문제

You are given an array $a$ of length $n$ consisting of non-negative integers. Calculate the number of pairs $(k, T)$ such that there exists a subsequence of $a$ of length $k$ whose sum is equal to $T$.

Just kidding, this is too general. Suppose the sum of elements of $a$ is equal to $S$, then it is guaranteed that $a$ has at least $S/5$ elements equal to $1$.

입력

The first line contains two positive integers $n$ and $S$ ($1 \le n, S \le 2 \cdot 10^5$) --- the number of elements in $a$ and their sum.

The second line contains the array $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le S$). It is guaranteed that $\sum_{i=1}^{n} a_i = S$ and at least $S/5$ elements of $a$ are equal to $1$.

출력

Print the number of pairs $(k, T)$ such that there exists a subsequence of $a$ of length $k$ whose sum is equal to $T$.

예제 입력 1

7 9
0 0 0 1 1 2 5

예제 출력 1

42

예제 입력 2

10 33
9 9 8 1 1 1 1 1 1 1

예제 출력 2

48

예제 입력 3

10 14
2 4 4 1 0 1 0 1 0 1

예제 출력 3

81

예제 입력 4

10 14
3 5 3 0 1 0 1 0 1 0

예제 출력 4

87