N,K = map(int,input().split())
a = list(map(int,input().split()))
c = []
c_re = [0]
tmp = 0
for e in a:
    tmp += e
    c.append(tmp)
tmp = 0
for e in reversed(a):
    tmp += e
    c_re.append(tmp)
c_re = list(reversed(c_re))
# sum(a) < K ならば0通り
# dp[i][j]:i番目までの子供,残っている飴の個数j ans = dp[N][0]
# 0 <= k <= min(c[i] ,K) - j
# dp[i][j] += dp[i-1][j+k]
dp = [[0]*(K+1) for i in range(N+1)]
dp[0][K] = 1
for i in range(1,N+1):
    inf = K - c[i-1] if K - c[i-1] > 0 else 0
    for j in range(inf,min(c_re[i],K) + 1):
        for k in range(min(a[i-1],K-j) + 1): 
            dp[i][j] += dp[i-1][j+k]
ans = dp[N][0] % (10**9 + 7)
print(ans)