import sys
MAX_INT = int(10e2)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
a = IL()

dp = [[0]*(K+1) for i in range(N+1)] # dp[i人までの子どもが][j個のアメを配る]
Cs = [[0]*(K+1) for i in range(N+1)] # 累積和

aa = a[0]
num = 0
for i in range(K+1):
  if i <= aa:
    dp[1][i] = 1
    num += 1
  Cs[1][i] = num
for i in range(2,N+1):
  num = 0
  for j in range(K+1):
    if j-a[i-1]-1 < 0:
      dp[i][j] = Cs[i-1][j]
    else:
      dp[i][j] = Cs[i-1][j] - Cs[i-1][j-a[i-1]-1]
    num += dp[i][j]
    Cs[i][j] = num

print(dp[N][K] %mod)