from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
from fractions import gcd

NN = 202020
MOD = 10**9+7
INF = float("inf")

n, k = map(int, input().split())
A = list(map(int, input().split()))
dp = [[[0]*3 for _ in range(k+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(n):
    for j in range(k+1):
        dp[i+1][j][0] = (dp[i+1][j][0] + dp[i][j][0])%MOD
        dp[i+1][j][1] = (dp[i+1][j][1] + dp[i][j][0] + dp[i][j][1])%MOD
        dp[i+1][j][2] = (dp[i+1][j][2] + dp[i][j][0] + dp[i][j][1] + dp[i][j][2])%MOD
        if j + A[i] <= k:
            dp[i+1][j+A[i]][1] = (dp[i+1][j+A[i]][1] + dp[i][j][0] + dp[i][j][1])%MOD
            dp[i+1][j+A[i]][2] = (dp[i+1][j+A[i]][2] + dp[i][j][0] + dp[i][j][1])%MOD

print(dp[n][k][2])
