import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9
    DP = [[0 for j in range(K + 1)] for i in range(N)]
    for i in range(A[0] + 1): DP[0][i] = 1
    for i in range(1, N):
        cum = [0] * (K + 2)
        for j in range(1, K + 2):
            cum[j] = (cum[j-1] + DP[i-1][j-1]) % mod
        #print(cum)
        for j in range(K + 1):
            DP[i][j] = (cum[j + 1] - cum[max(0, j - A[i])]) % mod
    print(DP[N-1][K])
    #print(DP)

    return 0

if __name__ == "__main__":
    solve()