import numpy as np
n,s=map(int,input().split())
t=np.zeros(s+1)
m=10**9+7
a=list(map(int,input().split()))
ans=0
for i in range(n):
    t[a[i]:]+=t[:-a[i]]
    if a[i]<s:
        t[a[i]]+=i+1
    ans+=t[-1]
    ans%=m
print(int(ans))