#include <bits/stdc++.h>
using namespace std;
const int maxn = 505 + 5;
const int mod = 998244353;
int an[maxn + 5];
long long dp[maxn * maxn + 5];
long long dfs(int l, int r) {
  if (l >= r) return 1;
  if (dp[l * maxn + r] != -1) return dp[l * maxn + r];
  long long ansleft = 0;
  long long ansright = 0;
  int p = l;
  int now_min = an[l];
  for (int i = l + 1; i <= r; i++) {
    if (now_min > an[i]) {
      p = i;
      now_min = an[i];
    }
  }
  for (int i = l - 1; i < p; i++) {
    ansleft = (ansleft + dfs(l, i) * dfs(i + 1, p - 1)) % mod;
  }
  for (int i = r + 1; i > p; i--) {
    ansright = (ansright + dfs(i, r) * dfs(p + 1, i - 1)) % mod;
  }
  dp[l * maxn + r] = (ansleft * ansright) % mod;
  return dp[l * maxn + r];
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    memset(dp, -1, sizeof(dp));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &an[i]);
    }
    printf("%lld\n", dfs(1, n));
  }
  return 0;
}
