import sys

input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(max(1000, 10**9))

write = lambda x: sys.stdout.write(x+"\n")





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

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



dp = [[0]*(k+1) for _ in range(n+1)]

cum = [1]*(k+2)

M = 10**9+7

for i in range(n+1):

    dp[i][0] = 1

cum[0] = 0

for i in range(1,n+1):

    current = [0]*(k+2)

    for j in range(k+1):

#         print(i,j,k,a[i])

        dp[i][j] = (cum[j+1] - cum[max(0, j-min(k,a[i-1]))]) % M

        current[j+1] = (current[j] + dp[i][j])%M

    cum = current

print((dp[n][k]))
import sys

input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(max(1000, 10**9))

write = lambda x: sys.stdout.write(x+"\n")





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

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



dp = [0]*(k+1)

cum = [1]*(k+2)

M = 10**9+7

dp[0] = 1

cum[0] = 0

for i in range(1,n+1):

    current = [0]*(k+2)

    for j in range(k+1):

        dp[j] = (cum[j+1] - cum[max(0, j-min(k,a[i-1]))]) % M

        current[j+1] = (current[j] + dp[j])%M

    cum = current

print((dp[k]))
import sys

input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
dp = [[0] * (k + 1) for _ in range(n + 1)]
cum = [1] * (k + 2)
M = 10**9 + 7
for i in range(n + 1):
    dp[i][0] = 1
cum[0] = 0
for i in range(1, n + 1):
    current = [0] * (k + 2)
    for j in range(k + 1):
        #         print(i,j,k,a[i])
        dp[i][j] = (cum[j + 1] - cum[max(0, j - min(k, a[i - 1]))]) % M
        current[j + 1] = (current[j] + dp[i][j]) % M
    cum = current
print((dp[n][k]))

import sys

input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
dp = [0] * (k + 1)
cum = [1] * (k + 2)
M = 10**9 + 7
dp[0] = 1
cum[0] = 0
for i in range(1, n + 1):
    current = [0] * (k + 2)
    for j in range(k + 1):
        dp[j] = (cum[j + 1] - cum[max(0, j - min(k, a[i - 1]))]) % M
        current[j + 1] = (current[j] + dp[j]) % M
    cum = current
print((dp[k]))

-dp = [[0] * (k + 1) for _ in range(n + 1)] +dp = [0] * (k + 1) -for i in range(n + 1): -    dp[i][0] = 1 +dp[0] = 1 -        #         print(i,j,k,a[i]) -        dp[i][j] = (cum[j + 1] - cum[max(0, j - min(k, a[i - 1]))]) % M -        current[j + 1] = (current[j] + dp[i][j]) % M +        dp[j] = (cum[j + 1] - cum[max(0, j - min(k, a[i - 1]))]) % M +        current[j + 1] = (current[j] + dp[j]) % M -print((dp[n][k])) +print((dp[k]))