def candies(k, a):
    mod = 10 ** 9 + 7
    cur = [0] * (k + 1)
    cur[0] = 1
    prefix = cur[:]
    nxt = cur[:]
    for x in a:
        for i in range(1, k + 1):
            prefix[i] = (prefix[i - 1] + cur[i]) % mod
        for i in range(1, k + 1):
            # nxt[i] = sum(cur[(i - x if i - x >= 0 else 0):i + 1]) % mod
            nxt[i] = (prefix[i] - (prefix[i - x - 1] if i - x - 1 >= 0 else 0)) % mod
        cur, nxt = nxt, cur
    return cur[k]


def main():
    n, k = [int(x) for x in input().split()]
    a = [int(x) for x in input().split()]
    return candies(k, a)


print(main())
