MOD = 998244353
inpl = lambda: list(map(int,input().split()))
N, S = inpl()
A = inpl()
B = sorted([(A[i], i) for i in range(N)],reverse=True)
C = [B[i][1] for i in range(N)]
ans = 0
comb = set()
pool = [(0,None,None,0)] # node, start, end, sum
while pool:
    i, start, end, s = pool.pop()
    if i < N-1:
        pool.append((i+1,start,end,s))
    s += A[C[i]]
    if start is None:
        start = end = C[i]
    elif C[i] < start:
        start = C[i]
    elif C[i] > end:
        end = C[i]
    if s == S:
        ans += (start+1) * (N-end)
        ans %= MOD
    elif s < S and i < N-1:
        pool.append((i+1,start,end,s))
print(ans)