#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353, n, m, a[505], f[505][505], g[505][505];
int main() {
  scanf("%lld%lld", &n, &m);
  for (register int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (register int i = 1; i <= n + 1; i++) {
    f[i][i - 1] = f[i][i] = g[i][i - 1] = g[i][i] = 1;
  }
  for (register int len = 2; len <= n; len++) {
    for (register int l = 1; l + len - 1 <= n; l++) {
      int r = l + len - 1;
      long long k, Min = 1ll << 60;
      for (register int i = l; i <= r; i++) {
        if (a[i] < Min) {
          Min = a[i];
          k = i;
        }
      }
      f[l][r] = g[l][r] = f[l][k - 1] * f[k + 1][r] % mod;
      for (k = l; k < r; k++) {
        f[l][r] = (f[l][r] + g[l][k] * f[k + 1][r] % mod) % mod;
      }
    }
  }
  printf("%lld\n", f[1][n]);
  return 0;
}
