def main():
    N, K = map(int, input().split())
    A = map(int, input().split())
    u = [1] + [0] * K
    v = [1] + [0] * K
    s = 1
    for a in A:
        u, v = v, u
        s += a
        c = 0
        for i, t in enumerate(u[:a + 1]):
            c += t
            v[i] = c
        for i, t, tt in zip(range(a + 1, K + 1), u[a + 1:s], u):
            c += t - tt
            v[i] = c
    print(v[K] % (10 ** 9 + 7))

main()
