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

for i in range(n):
    dp[i][0] = 1

sum_a = []
now = 0
for i in a:
    now += i
    sum_a.append(now)
#print(sum_a)
for i in range(n):
    for j in range(1,k+1):
        if sum_a[i] < j:
            dp[i][j] = 0
            break
        dp[i][j] = dp[i][j-1]
        if i > 0:
            dp[i][j] += dp[i-1][j]
            if j>a[i]:
                dp[i][j] -= dp[i-1][j-a[i]-1]

        dp[i][j] %= mod
        #print(i+1,j,dp[i][j])


print(dp[n-1][k])