# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=998244353
def input(): return sys.stdin.readline().rstrip()

def main():
    N,S=map(int,input().split())
    A=list(map(int,input().split()))
    dp=[[[0]*3 for _ in range(S+1)] for _ in range(N+1)]
    dp[0][0][0]=1
    for i in range(N):
        for j in range(S+1):
            dp[i+1][j][0]+=dp[i][j][0]
            dp[i+1][j][1]+=dp[i][j][0]+dp[i][j][1]
            dp[i+1][j][2]+=dp[i][j][0]+dp[i][j][1]+dp[i][j][2]
            if j+A[i]<=S:
                dp[i+1][j+A[i]][1]+=dp[i][j][0]+dp[i][j][1]
                dp[i+1][j+A[i]][2]+=dp[i][j][0]+dp[i][j][1]
    print(dp[-1][-1][2])

if __name__ == '__main__':
    main()
