#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long n, m, a[1010], f[1010][1010], pos[1010][1010];
long long dfs(int l, int r) {
  if (l > r) return 1;
  if (f[l][r] != -1) return f[l][r];
  int now = pos[l][r], res = 0, ans = 0;
  for (int i = l; i <= now; i++)
    ans = (ans + dfs(l, i - 1) * dfs(i, now - 1) % mod) % mod;
  for (int j = now; j <= r; j++)
    res = (res + ans * dfs(now + 1, j) % mod * dfs(j + 1, r) % mod) % mod;
  return f[l][r] = res;
}
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++) {
    long long minn = a[i];
    pos[i][i] = i;
    for (int j = i + 1; j <= n; j++) {
      if (a[j] < minn) {
        minn = a[j];
        pos[i][j] = j;
      } else
        pos[i][j] = pos[i][j - 1];
    }
  }
  memset(f, -1, sizeof(f));
  printf("%lld\n", dfs(1, n));
}
