N,S= map(int,input().split())
A= list(map(int,input().split()))

dp = [[0 for i in range(S+1)] for j in range(N+1)]
sumdp = [0 for i in range(S+1)]

dp[0][0] = 1
sumdp[0] = 1

for i in range(1,N+1):
    if A[i-1] <= S:
        dp[i][A[i-1]] += i
    for j in range(1,S+1):
        if j+A[i-1] > S:
            break
        dp[i][j+A[i-1]] += sumdp[j]
    for j in range(S+1):
        sumdp[j] += dp[i][j]
    
ans = 0
for i in range(1,N+1):
    ans += dp[i][S] * (N+1-i)
print(ans)

