#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k = map(int,input().split())
A = list(map(int,input().split()))
dp = [[0]*(k+1) for i in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
  ai = A[i-1]
  now = 0
  for ki in range(k+1):
    now += dp[i-1][ki]
    if ki - ai > 0:
      now -= dp[i-1][ki-ai-1]
    dp[i][ki] = now % mod
print(dp[n][k])
# print(dp)