import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = lambda: sys.stdin.readline().rstrip()

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

#dp[i][j]はi人に配り終えてj個残っている状態からの場合の数
dp = [[0 for _ in range(K+1)] for _ in range(N+1)]
dp[N][0] = 1
cum = [[0 for _ in range(K+1)] for _ in range(N+1)]
cum[N] = [1] * (K+1)
for i in range(N-1, -1, -1):
    for j in range(K+1):
        if j > a[i]:
            dp[i][j] = cum[i + 1][j] - cum[i + 1][j - a[i] - 1]
        else:
            dp[i][j] = cum[i+1][j]

        if j == 0:
            cum[i][j] = dp[i][j]
        else:
            cum[i][j] = cum[i][j-1] + dp[i][j]

print(dp[0][K] % (10**9+7))
