n,s = map(int, input().split( ))

*a, = map(int, input().split( ))

dp = [[0]*(3001) for i in range(n)]
dp[0][0] = 1
dp[0][a[0]] = 1

ans = 0

for i in range(1,n):
    for j in range(s+1):
        dp[i][j] += dp[i-1][j]
        if j>=a[i]:
            dp[i][j] += dp[i-1][j-a[i]]
    dp[i][0] +=1
    dp[i][a[i]] += 1
    ans += dp[i][s]
print(ans)