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

dp = [[0] * (n + 1) for i in range(k + 1)]
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]:
            dp[i][j] = 0
        elif i == 0:
            dp[i][j], cs_dp[i][j] = 1, 1
        elif i == 1:
            dp[i][j] = dp[i][j - 1] + min(1, a[j - 1])
        elif i - a[j - 1] - 1 < 0:
            dp[i][j] = cs_dp[i][j - 1]
        else:
            dp[i][j] = 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] + dp[i][j]

#print(dp)
print(dp[k][n] % (10 ** 9 + 7))
