N, K = list(map(int, input().split()))

A = list(map(int, input().split()))



from itertools import groupby, accumulate, product, permutations, combinations



def solve(N,K,A):

    mod = 10**9+7

    dp = [[0]*(K+1) for _ in range(N+1)] #dp[i][j] i人目まででj個を分ける場合の数

    dp[0][0] = 1

    for i in range(1,N+1):

        cum = list([x%mod for x in accumulate(dp[i-1])])

        for j in range(K+1):

            dp[i][j] = cum[j]

            k = j-A[i-1]

            if k>0:

                dp[i][j] -= cum[k-1]

    ans = dp[N][K]%mod

    return ans

print((solve(N,K,A)))
def solve():

  N, K = list(map(int, input().split()))

  A = list(map(int, input().split()))

  mod = 10**9+7

  dp = [[0]*(K+2) for _ in range(N+1)]

  dp[0] = [0]+[1]*(K+1)

  for n in range(1,N+1):

    for k in range(1,K+2):

      dp[n][k] = (dp[n-1][k]-dp[n-1][max(0,k-A[n-1]-1)]+dp[n][k-1])%mod

  ans = (dp[-1][-1]-dp[-1][-2])%mod

  return ans

print((solve()))
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
from itertools import groupby, accumulate, product, permutations, combinations


def solve(N, K, A):
    mod = 10**9 + 7
    dp = [[0] * (K + 1) for _ in range(N + 1)]  # dp[i][j] i人目まででj個を分ける場合の数
    dp[0][0] = 1
    for i in range(1, N + 1):
        cum = list([x % mod for x in accumulate(dp[i - 1])])
        for j in range(K + 1):
            dp[i][j] = cum[j]
            k = j - A[i - 1]
            if k > 0:
                dp[i][j] -= cum[k - 1]
    ans = dp[N][K] % mod
    return ans


print((solve(N, K, A)))

def solve():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    dp = [[0] * (K + 2) for _ in range(N + 1)]
    dp[0] = [0] + [1] * (K + 1)
    for n in range(1, N + 1):
        for k in range(1, K + 2):
            dp[n][k] = (
                dp[n - 1][k] - dp[n - 1][max(0, k - A[n - 1] - 1)] + dp[n][k - 1]
            ) % mod
    ans = (dp[-1][-1] - dp[-1][-2]) % mod
    return ans


print((solve()))

-N, K = list(map(int, input().split())) -A = list(map(int, input().split())) -from itertools import groupby, accumulate, product, permutations, combinations - - -def solve(N, K, A): +def solve(): +    N, K = list(map(int, input().split())) +    A = list(map(int, input().split())) -    dp = [[0] * (K + 1) for _ in range(N + 1)]  # dp[i][j] i人目まででj個を分ける場合の数 -    dp[0][0] = 1 -    for i in range(1, N + 1): -        cum = list([x % mod for x in accumulate(dp[i - 1])]) -        for j in range(K + 1): -            dp[i][j] = cum[j] -            k = j - A[i - 1] -            if k > 0: -                dp[i][j] -= cum[k - 1] -    ans = dp[N][K] % mod +    dp = [[0] * (K + 2) for _ in range(N + 1)] +    dp[0] = [0] + [1] * (K + 1) +    for n in range(1, N + 1): +        for k in range(1, K + 2): +            dp[n][k] = ( +                dp[n - 1][k] - dp[n - 1][max(0, k - A[n - 1] - 1)] + dp[n][k - 1] +            ) % mod +    ans = (dp[-1][-1] - dp[-1][-2]) % mod -print((solve(N, K, A))) +print((solve()))