N, K = map(int, input().split())
a = [0] + list(map(int, input().split()))
DP = [[0 for k in range(K+1)] for n in range(N+1)]
cs = [[0 for k in range(K+2)] for n in range(N+1)]
for i in range(1,N+1):
    for j in range(0,K+2):
        if i == 1 and j <= K:
            if j <= a[i]:
                DP[i][j] = 1
            else:
                DP[i][j] = 0
        elif j <= K:
            DP[i][j] += (cs[i-1][j+1] - cs[i-1][max(j-a[i],0)])%(10**9+7)
        if j > 0:
            cs[i][j] = (cs[i][j-1]%(10**9+7) + DP[i][j-1]%(10**9+7))%(10**9+7)
print(DP[N][K])