import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
from functools import lru_cache
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
a=list(map(int,input().split()))

dp=[[0]*(k+1) for j in range(n+1)]

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

for i in range(1,n+1):
    for j in range(1,k+1):
        dp[i][j]=dp[i-1][j]+dp[i][j-1]
        if j-a[i-1]-1 >= 0:
            dp[i][j]-=dp[i-1][j-a[i-1]-1]
        dp[i][j]%=mod
# print(dp)
print(dp[n][k])