mod = 10**9 + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [[0]*(k+10) for _ in range(2)]
b[0][0] = b[0][1] = 1
f = 1
for x in a:
  for i in range(1, k + 1):
    b[f][i] = b[f^1][i]
    if i > x:
      b[f][i] -= b[f^1][i-x-1]
    b[f][i] = (b[f][i] + b[f][i-1]) % mod
  f ^= 1
print((b[f^1][k] - b[f^1][k-1]) % mod)