#include //#include //using mint=atcoder::modint998244353; using namespace std; typedef long long ll; #define rep(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++) #define rrep(i,a,b) for(ll i=(ll)(a-1);i>=(ll)(b);i--) #define MOD 998244353 //#define MOD 1000000007 #define INF 1e18 #define Pair pair //#define PI numbers::pi //#define E numbers::e template bool chmax(T& a,T b){if(a bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} ll dx[8]={-2,-1,1,2,-2,-1,1,2}; ll dy[8]={-1,-2,-2,-1,1,2,2,1}; int main(){ ll n,k; cin >> n >> k; vector a(n); rep(i,0,n) cin >> a[i]; vector>> dp(n+1); dp[0].insert({{0,0},0}); rep(i,0,n){ for(auto&& x:dp[i]){ ll p=x.first.first,q=x.first.second,r=x.second; if(r==k) dp[i+1].insert(x); else if(n-i+r==k&&(p+a[i]%998)%998>=(q+a[i]%MOD)%MOD) dp[i+1].insert({{(p+a[i]%998)%998,(q+a[i]%MOD)%MOD},r+1}); else{ dp[i+1].insert(x); if(r=(q+a[i]%MOD)%MOD) dp[i+1].insert({{(p+a[i]%998)%998,(q+a[i]%MOD)%MOD},r+1}); } } } ll ans=0; for(auto&& x:dp[n]){ ll p=x.first.first,q=x.first.second,r=x.second; if(r==k&&q<=p) ans++; } cout << ans%998 << endl; }