import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, S = mi()
A = li()

l = [[] for i in range(3005)]
#l[0].append([0, 0])
#print(l)
for i, num in enumerate(A):
    l[num].append([i, i])
    for j in reversed(range(S-num+1)):
        #print(i, j, l)
        if l[j] != []:
            for st in l[j]:
                if st != [i, i]:
                    l[j+num].append([st[0], i])

#print(l[10])
ans = 0
for st in l[S]:
    ans = ans + (st[0]+1)*(N-st[1])
print(ans)