mod = 10**9+7
N,K = map(int,input().split())
a = list(map(int,input().split()))
dp = [[0]*(K+1) for _ in range(N+1)]
for n in range(N+1):
    dp[n][0] = 1

for n in range(N):
    for k in range(1,K+1):
        if k-1-a[i] >= 0:
            dp[n+1][k] = dp[n+1][k-1]-dp[n][k-1-a[n]]
        else:
            dp[n+1][k] = dp[n][k]+dp[n+1][k-1]
        dp[n+1][k] %= mod

print(dp[N][K])