n, k = map(int, input().split())
a = list(map(int, input().split()))

cs_a, cnt = [0] * n, 0
for i in range(n):
    cnt += a[i]
    cs_a[i] = cnt

cs_dp = [[0] * (n + 1) for i in range(k + 1)]

for i in range(k + 1):
    for j in range(1, n + 1):
        if i > cs_a[j - 1]:
            tmp = 0
        elif i == 0:
            cs_dp[i][j] = 1
        elif i == 1:
            tmp = cs_dp[i][j - 1] - cs_dp[i - 1][j - 1] + min(1, a[j - 1])
        elif i - a[j - 1] - 1 < 0:
            tmp = cs_dp[i][j - 1]
        else:
            tmp = cs_dp[i][j - 1] - cs_dp[i - a[j - 1] - 1][j - 1]
        if i > 0:
            cs_dp[i][j] = (cs_dp[i - 1][j] + tmp)%(10**9+7)

#print(dp)
print(cs_dp[k][n] - cs_dp[k - 1][n] if k > 0 else cs_dp[k][n])

