#include <bits/stdc++.h>
using namespace std;
const int N = 500 + 5;
long long cnt[N];
long long arra[N];
long long minimum[N][N];
long long dp[N][N];
long long solve(long long l, long long r) {
  if (r - l == 1) {
    return 1;
  }
  long long &ret = dp[l][r];
  if (ret != -1) return ret;
  long long mini = minimum[l][r];
  long long pos = cnt[mini];
  long long ans = 0, temp = 1;
  long long t1 = 0, t2 = 0;
  for (long long i = l; i <= pos; i++) {
    temp = 1;
    if (i > l) temp *= solve(l, i);
    temp %= 998244353;
    if (pos > i) temp *= solve(i, pos);
    temp %= 998244353;
    t1 += temp;
    t1 %= 998244353;
  }
  for (long long j = pos + 1; j <= r; j++) {
    temp = 1;
    if (r > j) temp *= solve(j, r);
    temp %= 998244353;
    if (j > pos + 1) temp *= solve(pos + 1, j);
    temp %= 998244353;
    t2 += temp;
    t2 %= 998244353;
  }
  ans = t1 * t2;
  return ret = ans % 998244353;
}
int main() {
  memset(dp, -1, sizeof dp);
  long long n, m;
  scanf("%lld %lld", &n, &m);
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &arra[i]);
    cnt[arra[i]] = i;
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j <= n; j++) {
      long long mini = INT_MAX;
      for (long long k = i; k < j; k++) mini = min(mini, arra[k]);
      minimum[i][j] = mini;
    }
  }
  printf("%lld", solve(0, n));
  return 0;
}
