N,S= map(int,input().split())
a_list = list(map(int,input().split()))
# dp[i][j]: i番目までの数字を使ってjを作るときに左端の数字
dp = [[[] for _ in range(S+1)] for _ in range(N+1)]
for i in range(1,N+1):
    ai = a_list[i-1]
    for j in range(1,S+1):
        if j == ai:
            dp[i][j] = [i]
        conj = j - ai
        if conj > 0:
            dpij = []
            for ii in range(1,i):
                dpij += dp[ii][conj]
            dp[i][j] += dpij
        
li = []
for i in range(1,N+1):
    temp = [(k,i) for k in dp[i][S]]
    li += temp

# print(li)

ans = 0
for l,r in li:
    ans += l * (N+1-r)
print(ans)