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

mod = 1000000007

# dp
# dp[i][j]: i人目にj個目の飴を配る時のパターン
dp = [[0] * (K + 1) for i in range(N + 1)]

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

for i in range(N):
  for j in range(K):

    if a[i] < j + 1:
      dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1] - dp[i][j - a[i]]) % mod
    else:
      dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1]) % mod
  
print(dp[N][K])