#include <bits/stdc++.h>
using namespace std;
long long i, j, k, l, n, m, sz, res, pos, mini, r;
long long dp[509][509], a[509];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 0; i <= n; i++) {
    dp[i + 1][i] = 1;
  }
  for (r = 1; r <= n; r++) {
    mini = ((long long)1e18 + 9ll);
    for (l = r; l > 0; l--) {
      if (a[l] < mini) {
        mini = a[l];
        pos = l;
      }
      for (i = l; i <= pos; i++) {
        dp[l][r] = (dp[l][r] + (dp[l][i - 1] * dp[i][pos - 1]) % 998244353) %
                   998244353;
      }
      k = 0;
      for (i = pos; i <= r; i++) {
        k = (k + (dp[pos + 1][i] * dp[i + 1][r]) % 998244353) % 998244353;
      }
      dp[l][r] = (dp[l][r] * k) % 998244353;
    }
  }
  cout << dp[1][n] << '\n';
  exit(0);
}
