import sys
sys.setrecursionlimit(100000000)

N, K = map(int, raw_input().split())
A = list(map(int, raw_input().split()))
possible_ways = {}

def get_possible_ways(i, k):
    if i >= N or k < 0:
        return 0
    if k == 0:
        return 1
    if i == N-1 and k <= A[i]:
        return 1

    if (i, k) in possible_ways:
        return possible_ways[i, k]

    ways = 0
    if A[i] > k:
        R = range(k+1)
    else:
        R = range(A[i] + 1)
    for x in R:
        ans = get_possible_ways(i+1, k-x)
        if ans > 1000000007:
            ans -= 100000007
        ways += get_possible_ways(i+1, k-x)


    possible_ways[i, k] = ways

    return ways

print get_possible_ways(0, K)