#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 505;
const int mod = 998244353;
int n, m, a[N], memo[N][N];
int add(int a, int b) { return (a + b) % mod; }
int mul(int a, int b) { return (1ll * a * b) % mod; }
int solve(int l, int r) {
  if (l >= r) return 1;
  int &ans = memo[l][r];
  if (~ans) return ans;
  ans = 0;
  int x = 0, mn = 1e9, p;
  for (int i = l; i <= r; i++)
    if (a[i] < mn) mn = a[i], p = i;
  for (int i = l; i <= p; i++)
    x = add(x, mul(solve(l, i - 1), solve(i, p - 1)));
  for (int j = p; j <= r; j++)
    ans = add(ans, mul(x, mul(solve(p + 1, j), solve(j + 1, r))));
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  memset(memo, -1, sizeof memo);
  cout << solve(0, n - 1);
  return 0;
}
