local n,k=io.read("n","n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end

local dp={}
for i=1,n+1 do
    dp[i]={}
    dp[i][1]=1
    for j=2,k+1 do
        dp[i][j]=0
    end
end

local mod=1000000007
for i=1,n do
    for j=2,k+1 do
        if j-1-a[i]>0 then
            dp[i+1][j]=(dp[i+1][j-1]+dp[i][j]-dp[i][j-1-a[i]])%mod
        else
            dp[i+1][j]=(dp[i+1][j-1]+dp[i][j])%mod
        end
    end
end
print(dp[n+1][k+1])