#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 3e3+5,mod = 998244353,g = 3,ig = 332748118;
it add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
it mul(int x,int y){return 1ll*x*y%mod;}
il inc(int &x,int y){x=add(x,y);}
int n,m,ans,val[N];
struct Seg_Tree{
	int dp[N];
	Seg_Tree(){del(dp,0);}
}T[N<<2];
#define lc (cur<<1)
#define rc (cur<<1|1)
int a[N<<2],b[N<<2],lim=1,len,rev[N<<2];
il NTT(int a[],int ty){
	for(ri i=0;i<lim;++i)
		if(i<rev[i])
			swap(a[i],a[rev[i]]);
	for(ri md=1;md<lim;md<<=1){
		int w_n=qpow(ty==1?g:ig,(mod-1)/(md<<1),mod);
		for(ri r=md<<1,j=0;j<lim;j+=r){
			int w=1;
			for(ri k=0;k<md;++k,w=mul(w,w_n)){
				int x=a[j+k],y=mul(w,a[j+md+k]);
				a[j+k]=add(x,y),a[j+md+k]=add(x,mod-y);
			}
		}
	}
}
Seg_Tree Merge(Seg_Tree x,Seg_Tree y){
	Seg_Tree res;
	for(ri i=1;i<=m;++i) a[i]=x.dp[i];
	for(ri i=1;i<=m;++i) b[i]=y.dp[i];
	for(ri i=m+1;i<lim;++i) a[i]=b[i]=0;
	a[0]=b[0]=1;
	NTT(a,1),NTT(b,1);
	for(ri i=0;i<lim;++i) a[i]=mul(a[i],b[i]);
	NTT(a,-1);
	int inv=qpow(lim,mod-2,mod);
	for(ri i=0;i<=m;++i) res.dp[i]=mul(a[i],inv);
	return res;
}
il Build(int cur,int l,int r){
	if(l==r) return T[cur].dp[val[l]]=1,void();
	Build(lc,l,mid),Build(rc,mid+1,r);
	T[cur]=Merge(T[lc],T[rc]);
}
Seg_Tree Query(int cur,int l,int r,int L,int R){
	if(l==L&&r==R) return T[cur];
	if(mid>=R) return Query(lc,l,mid,L,R);
	if(mid<L) return Query(rc,mid+1,r,L,R);
	return Merge(Query(lc,l,mid,L,mid),Query(rc,mid+1,r,mid+1,R));
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m);
	for(ri i=1;i<=n;++i)
		read(val[i]);
	for(;lim<=m+m;lim<<=1) ++len;
	for(ri i=0;i<lim;++i) rev[i]=(rev[i>>1]>>1)|((i&1)<<(len-1));
	Build(1,1,n);
	for(ri i=1;i<=n;++i)
		for(ri j=i;j<=n;++j)
			inc(ans,Query(1,1,n,i,j).dp[m]);
	print(ans);
	return 0;
}