#DP頓挫乙

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

DP=[[[] for j in range(3001)] for i in range(N)]
DP[0][A[0]].append([0, 0])
for i in range(1, N):
  DP[i][A[i]].append([i, i])
  for j in range(3001):
    DP[i][j]+=DP[i-1][j]
  for j in range(A[i]+1, 3001):
    tmp=DP[i-1][j-A[i]]
    for k in range(tmp):
      DP[i][j].append([k[0], j])