#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353ll;
long long dp[505][505];
int c[505];
int main() {
  int N;
  scanf("%d %d", &N, &N);
  for (int i = 1; i <= N; i++) scanf("%d", c + i);
  for (int i = 1; i <= N + 1; i++) dp[i][i - 1] = dp[i][i] = 1ll;
  dp[0][0] = 1ll;
  for (int i = 2; i <= N; i++)
    for (int j = 1; i + j - 1 <= N; j++) {
      int k = j;
      for (int l = j + 1; l <= i + j - 1; l++)
        if (c[l] < c[k]) k = l;
      long long a = 0ll, b = 0ll;
      for (int l = j; l <= k; l++) a += dp[j][l - 1] * dp[l][k - 1] % MOD;
      for (int l = k; l <= i + j - 1; l++)
        b += dp[k + 1][l] * dp[l + 1][i + j - 1] % MOD;
      a %= MOD;
      b %= MOD;
      dp[j][i + j - 1] = a * b % MOD;
    }
  printf("%lld", dp[1][N]);
  return 0;
}
