#include <bits/stdc++.h>
using namespace std;
string s;
const long long MOD = 998244353;
vector<int> a;
long long dp[501][501];
int n, m;
void calc(int i, int j) {
  if (i == j)
    dp[i][j] = 1;
  else {
    int mm = 1e9;
    int pos = -1;
    for (int k = i; k < j; k++) {
      if (mm > a[k]) {
        mm = a[k];
        pos = k;
      }
    }
    int k = pos;
    long long delta1[2];
    delta1[0] = 0;
    delta1[1] = 0;
    for (int x = i; x <= k; x++) {
      long long delta = 1;
      delta *= dp[i][x];
      delta %= MOD;
      delta *= dp[x][k];
      delta %= MOD;
      delta1[0] += delta;
      delta1[0] %= MOD;
    }
    for (int y = k + 1; y <= j; y++) {
      long long delta = 1;
      delta *= dp[k + 1][y];
      delta %= MOD;
      delta *= dp[y][j];
      delta %= MOD;
      delta1[1] += delta;
      delta1[1] %= MOD;
    }
    delta1[0] *= delta1[1];
    delta1[0] %= MOD;
    dp[i][j] += delta1[0];
    dp[i][j] %= MOD;
  }
}
void calc_dp() {
  for (int delta = 0; delta < n + 10; delta++) {
    for (int alp = 0; alp < n + 10; alp++) {
      if (alp + delta <= n) calc(alp, alp + delta);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  calc_dp();
  cout << dp[0][n];
  return 0;
}
