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

a = tuple(map(int, input().split()))



def main():

    l = [1 if a[0] >= j else 0 for j in range(K+1)]

    lt= [0] * (K+1)

    s = a[0]

    for i in range(1,N):

        lt, l = l, lt

        s += a[i]

        l[0] = 1

        t = 1

        for j in range(1, a[i]+1):

                t += lt[j]

                l[j] = t

        for j in range(a[i]+1, min(K+1, s+1)):

                t += (lt[j] - lt[j - a[i] - 1])

                l[j] = t

    return l[-1] % (10 ** 9 + 7)

            

print((main()))

def main():

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

    a = tuple(map(int, input().split()))

    l = [1 if a[0] >= j else 0 for j in range(K+1)]

    lt= [1 if a[0] >= j else 0 for j in range(K+1)]

    s = a[0]

    for i in a[1:]:

        lt, l = l, lt

        s += i

        l[0] = 1

        t = 1

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

                t += lt[j]

                l[j] = t

        for j in range(i+1, min(K+1, s+1)):

                t += (lt[j] - lt[j - i - 1])

                l[j] = t

    return l[-1] % (10 ** 9 + 7)

            

print((main()))

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


def main():
    l = [1 if a[0] >= j else 0 for j in range(K + 1)]
    lt = [0] * (K + 1)
    s = a[0]
    for i in range(1, N):
        lt, l = l, lt
        s += a[i]
        l[0] = 1
        t = 1
        for j in range(1, a[i] + 1):
            t += lt[j]
            l[j] = t
        for j in range(a[i] + 1, min(K + 1, s + 1)):
            t += lt[j] - lt[j - a[i] - 1]
            l[j] = t
    return l[-1] % (10**9 + 7)


print((main()))

def main():
    N, K = list(map(int, input().split()))
    a = tuple(map(int, input().split()))
    l = [1 if a[0] >= j else 0 for j in range(K + 1)]
    lt = [1 if a[0] >= j else 0 for j in range(K + 1)]
    s = a[0]
    for i in a[1:]:
        lt, l = l, lt
        s += i
        l[0] = 1
        t = 1
        for j in range(1, i + 1):
            t += lt[j]
            l[j] = t
        for j in range(i + 1, min(K + 1, s + 1)):
            t += lt[j] - lt[j - i - 1]
            l[j] = t
    return l[-1] % (10**9 + 7)


print((main()))

-N, K = list(map(int, input().split())) -a = tuple(map(int, input().split())) - - +    N, K = list(map(int, input().split())) +    a = tuple(map(int, input().split())) -    lt = [0] * (K + 1) +    lt = [1 if a[0] >= j else 0 for j in range(K + 1)] -    for i in range(1, N): +    for i in a[1:]: -        s += a[i] +        s += i -        for j in range(1, a[i] + 1): +        for j in range(1, i + 1): -        for j in range(a[i] + 1, min(K + 1, s + 1)): -            t += lt[j] - lt[j - a[i] - 1] +        for j in range(i + 1, min(K + 1, s + 1)): +            t += lt[j] - lt[j - i - 1]