import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 1e9+7

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


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

dp[n][0]=1

prefix = [[0]*(k+1) for i in range(n+1)]
# prefix[n][0]=1
for kk in range(k+1):
    prefix[n][kk]=1

for i in range(n-1, -1, -1):
    for kLeft in range(0, k+1):
        dp[i][kLeft] = (prefix[i+1][kLeft]-(prefix[i+1][kLeft-a[i]-1] if kLeft-a[i]-1>=0 else 0+MOD))%MOD
        prefix[i][kLeft] = ((prefix[i][kLeft-1] if kLeft-1>=0 else 0)+dp[i][kLeft])%MOD



print(int(dp[0][k]%int(MOD)))
