#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
template <typename T>
static ostream& operator<<(ostream& stream, const vector<T>& t);
template <typename T>
static istream& read(T, T, istream& = cin);
template <typename T>
static istream& operator>>(istream& stream, vector<T>& t) {
  return read((t).begin(), (t).end(), stream);
}
template <typename T>
static istream& read(T b, T e, istream& stream) {
  for (T it = b; it != e; ++it) stream >> *it;
  return stream;
}
template <typename T>
static void print(T x, string end = "\n") {
  cout << x << end;
}
const int N = 505;
long long dp[N][N];
void _() {
  int n, m;
  cin >> n >> m;
  vector<int> arr(n);
  cin >> arr;
  for (int i = 0; i < n; ++i) {
    dp[i][i] = 1;
  }
  for (int s = 2; s <= n; ++s)
    for (int l = 0; l <= n - s; ++l) {
      int r = l + s - 1;
      int smallest = l;
      for (int i = l; i <= r; ++i)
        if (arr[i] < arr[smallest]) smallest = i;
      long long left_stuff = 1;
      if (l < smallest) left_stuff *= dp[l][smallest - 1];
      long long right_stuff = 1;
      if (r > smallest) right_stuff *= dp[smallest + 1][r];
      for (int i = smallest - 1; i >= l; --i) {
        if (i == l)
          left_stuff += dp[l][smallest - 1];
        else
          left_stuff += dp[i][smallest - 1] * dp[l][i - 1] % MOD;
      }
      left_stuff %= MOD;
      for (int i = smallest + 1; i <= r; ++i) {
        if (i == r)
          right_stuff += dp[smallest + 1][r];
        else
          right_stuff += dp[smallest + 1][i] * dp[i + 1][r] % MOD;
      }
      right_stuff %= MOD;
      dp[l][r] = right_stuff * left_stuff % MOD;
    }
  print(dp[0][n - 1]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);
  _();
}
