#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
long long dp[510][510];
int t[510];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, i, len, j, l, r;
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> t[i];
  for (len = 1; len <= n; len++) {
    for (l = 1; l + len - 1 <= n; l++) {
      r = l + len - 1;
      if (len == 1) {
        dp[l][r] = 1;
        continue;
      }
      int mi = l;
      for (i = l; i <= r; i++)
        if (t[i] < t[mi]) mi = i;
      long long sl = dp[l][mi - 1] * 2 % mod;
      long long sr = dp[mi + 1][r] * 2 % mod;
      for (i = l; i + 1 < mi; i++)
        sl = (sl + dp[l][i] * dp[i + 1][mi - 1]) % mod;
      for (i = mi + 1; i <= r; i++)
        sr = (sr + dp[mi + 1][i] * dp[i + 1][r]) % mod;
      sl = max(sl, (long long)1);
      sr = max(sr, (long long)1);
      dp[l][r] = (sl * sr) % mod;
    }
  }
  cout << dp[1][n];
}
