#include <bits/stdc++.h>
using namespace std;
const long long maxn = 505;
const long long dd = 998244353;
long long n, m;
long long a[maxn], dp[maxn][maxn], col[maxn][maxn];
inline long long read() {
  long long ret = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = ret * 10 + ch - '0';
    ch = getchar();
  }
  return ret * f;
}
long long dfs(long long l, long long r) {
  if (l >= r) return 1;
  if (dp[l][r]) return dp[l][r];
  long long x = col[l][r];
  long long ans1 = 0, ans2 = 0;
  for (long long k = l - 1; k < x; k++)
    ans1 = (ans1 + dfs(l, k) * dfs(k + 1, x - 1)) % dd;
  for (long long k = r + 1; k > x; k--)
    ans2 = (ans2 + dfs(k, r) * dfs(x + 1, k - 1)) % dd;
  if (l == x) ans1 = 1;
  if (r == x) ans2 = 1;
  return dp[l][r] = ans1 * ans2 % dd;
}
signed main() {
  n = read();
  m = read();
  for (long long k = 1; k <= n; k++) a[k] = read();
  for (long long k = 1; k <= n; k++) {
    long long now = k;
    for (long long j = k; j <= n; j++)
      col[k][j] = a[j] > a[now] ? now : now = j;
  }
  printf("%lld\n", dfs(1, n));
  return 0;
}
