#include <bits/stdc++.h>
using namespace std;
long long f[505][505], n, m, mod = 998244353, c[501];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    f[i][i] = 1;
    f[i][i - 1] = 1;
  }
  f[n + 1][n] = 1;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j + i <= n; j++) {
      int l = j, r = j + i;
      int t1 = 1000, t2;
      for (int k = l; k <= r; k++) {
        if (t1 > c[k]) {
          t1 = c[k];
          t2 = k;
        }
      }
      long long right = 0, left = 0;
      for (int k = l; k <= t2; k++) {
        left += f[l][k - 1] * f[k][t2 - 1];
        left %= mod;
      }
      for (int k = t2; k <= r; k++) {
        right += f[t2 + 1][k] * f[k + 1][r];
        right %= mod;
      }
      f[l][r] = left * right;
      f[l][r] %= mod;
    }
  }
  cout << f[1][n];
  return 0;
}
