from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,S=map(int,readline().split())
    A=list(map(int,readline().split()))

    dp=[[0]*N for _ in range(N)]
    for i in range(N):
        if A[i]==S:
            dp[i][i]=1
    count=0
    for _ in range(N-1,0,-1):
        count+=1
        for i in range(_,0,-1):
            j=i+count
            i-=1
            j-=1
            dp[i][j]=dp[i+1][j]+dp[i][j-1]
            if A[i]+A[j]==S:
                dp[i][j]+=1

    s=0
    for i in range(N):
        for j in range(N):
            s+=dp[i][j]
            s%=998244353

    print(s)

if __name__=="__main__":
    main()