#include <bits/stdc++.h>
using namespace std;
int n, m;
int s[510];
long long dp[510][510], sgl[510][510];
int main() {
  s[0] = 0x3f3f3f3f;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
  for (int i = 1; i <= n + 1; i++)
    dp[i][i] = dp[i][i - 1] = sgl[i][i] = sgl[i][i - 1] = 1;
  for (int i = 1; i < n; i++) {
    for (int l = 1; i + l <= n; l++) {
      int r = l + i;
      int ne = 0;
      for (int j = l; j <= r; j++) ne = (s[j] < s[ne] ? j : ne);
      sgl[l][r] = (dp[l][ne - 1] * dp[ne + 1][r]) % 998244353;
      for (int j = l; j <= r; j++)
        (dp[l][r] += (sgl[l][j] * dp[j + 1][r]) % 998244353) %= 998244353;
    }
  }
  printf("%lld", dp[1][n]);
}
