#include <bits/stdc++.h>
using namespace std;
int n, a[507], p[507], m;
long long f[507][507], lows[507][507];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]), p[a[i]] = i, lows[i][i] = a[i];
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      lows[i][j] = min(lows[i][j - 1], 1ll * a[j]);
  for (int i = 0; i <= n + 1; i++)
    for (int j = 0; j <= n + 1; j++) f[i][j] = 1;
  for (int i = 1; i <= n; i++) {
    for (int l = 1; l + i - 1 <= n; l++) {
      int r = l + i - 1;
      int low = lows[l][r];
      int pos = p[low];
      long long w1 = 0, w2 = 0;
      for (int l1 = l; l1 <= pos; l1++)
        w1 = (w1 + f[l][l1 - 1] * f[l1][pos - 1] % 998244353) % 998244353;
      for (int r1 = pos; r1 <= r; r1++)
        w2 = (w2 + f[pos + 1][r1] * f[r1 + 1][r] % 998244353) % 998244353;
      if (!w1) w1 = 1;
      if (!w2) w2 = 1;
      f[l][r] = w1 * w2 % 998244353;
    }
  }
  cout << f[1][n] % 998244353 << endl;
  return 0;
}
