n, s = map(int,input().split())
alist = list(map(int, input().split()))
kago=[]
for i in range(s):
    kago.append([])

answer=0
for i in range(n):
    now=alist[i]
    for k in range(n):
        j=s-k-1
        if j-now>=0:
            kago[j]+=kago[j-now]
    if now-1<len(kago):
        kago[now-1].append(i)
    for kg in kago[-1]:
        answer+=(kg+1)*(n-i)
    kago[-1]=[]
    
    """
    for kg in kago:
        print(kg)
    
    print(answer)
    """
    #print()
    
print(answer)