#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   const long long INF = 1e18L + 7;   template <class n, class second>   ostream &operator<<(ostream &p, pair<n, second> x) {     return p <<  <  << x.first <<  ,   << x.second <<  > ;   }   template <class n>   auto operator<<(ostream &p, n y) ->       typename enable_if<!is_same<n, string>::value,                          decltype(y.begin(), p)>::type {     int o = 0;     p <<  { ;     for (auto c : y) {       if (o++) p <<  ,  ;       p << c;     }     return p <<  } ;   }   void dor() { cerr <<   n ; }   template <class n, class... second>   void dor(n p, second... y) {     cerr << p <<    ;     dor(y...);   }   template <class n, class second>   void mini(n &p, second y) {     if (p > y) p = y;   }   template <class n, class second>   void maxi(n &p, second y) {     if (p < y) p = y;   }   const int mod = 998244353;   const int N = 507;   int n, m;   int tab[N];   int dp[N][N][3];   int vis[N][N][3];   int pie[N];   int dru[N];   void solve(int a, int b, int t) {     if (vis[a][b][t]) return;     vis[a][b][t] = 1;     if (a > b) {       if (t == 2)         dp[a][b][t] = 1;       else         dp[a][b][t] = 0;       return;     }     int col = inf;     int ind = -1;     if (t == 2) {       for (int i = a; i <= b; ++i) {         if (col > tab[i]) {           col = tab[i];           ind = i;         }       }       solve(a, ind, 1);       solve(ind, b, 0);       dp[a][b][t] = (long long)dp[a][ind][1] * dp[ind][b][0] % mod;     } else if (t == 0) {       for (int i = a; i <= b; ++i) {         solve(a + 1, i, 2);         solve(i + 1, b, 2);         dp[a][b][t] += (long long)dp[a + 1][i][2] * dp[i + 1][b][2] % mod;         if (dp[a][b][t] >= mod) dp[a][b][t] -= mod;       }     } else if (t == 1) {       for (int i = a; i <= b; ++i) {         solve(a, i - 1, 2);         solve(i, b - 1, 2);         dp[a][b][t] += (long long)dp[a][i - 1][2] * dp[i][b - 1][2] % mod;         if (dp[a][b][t] >= mod) dp[a][b][t] -= mod;       }     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       cin >> tab[i];     }     solve(1, n, 2);     cout << dp[1][n][2] <<   n ;   }   