import sys
sys.setrecursionlimit(10**9)

BIG_INT = 10 ** 9 + 7

def dpcalc(N, K):
    dp = [[0] * (K +1) for _ in range(N + 1)]
    dp[0][0] = 1
    rs = [0] * (K + 2)
    
    for j in range(1, N + 1):
        rs[0] = 0
        for i in range(1, K + 2):
            rs[i] = rs[i-1] + dp[j-1][i-1]
        # print(rs)    
        for i in range(K+1):
            dp[j][i] = rs[i+1] -rs[max(0, i-A[j-1])]

    # print(dp)
    return dp[N][K]


N, K = map(int, input().split())
A = [int(x) for x in input().split()]


print(dpcalc(N, K)  % BIG_INT)
