def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys
    import heapq
    # from math import *
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return list(map(int, data().split()))
    out = sys.stdout.write
    # sys.setrecursionlimit(100000)
    INF = int(1e9)
    mod = int(1e9)+7

    n,k=mdata()
    A=mdata()
    dp=[1 if A[0]>=i else 0 for i in range(k+1)]
    for i in range(1,n):
        for j in range(1,k+1):
            dp[j]+=dp[j-1]
        for j in range(k+1):
            if A[i]<j:
                dp[j]-=dp[j-A[i]-1]
    print(dp[-1]%mod)



if __name__ == '__main__':
    main()