#include <bits/stdc++.h>
using namespace std;
long long A[501], pos[501], dp[501][501], LO[501][501];
long long solve(int l, int r) {
  if (l >= r) return 1;
  if (dp[l][r] != -1) return dp[l][r];
  long long p = pos[LO[l][r]];
  long long left = 0, right = 0;
  for (int i = l - 1; i < p; i++) {
    left += (solve(l, i) * solve(i + 1, p - 1)) % 998244353;
    left %= 998244353;
  }
  for (int i = p; i <= r; i++) {
    right += (solve(p + 1, i) * solve(i + 1, r)) % 998244353;
    right %= 998244353;
  }
  return dp[l][r] = (max(1LL, left) * max(1LL, right)) % 998244353;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    pos[A[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    long long mn = A[i];
    for (int j = i; j <= n; j++) {
      LO[i][j] = min(mn, A[j]);
      mn = LO[i][j];
    }
  }
  memset(dp, -1, sizeof(dp));
  cout << solve(1, n);
  return 0;
}
