#include <bits/stdc++.h>
using namespace std;
int N, M;
int A[505], B[505][505];
long long dp[505][505];
long long f(int L, int R) {
  if (L > R) return 1;
  long long &ret = dp[L][R];
  if (ret != -1) return ret;
  ret = 0;
  int mid = B[L][R];
  long long LS = 0, RS = 0;
  for (int i = L; i <= mid; i++) {
    LS += f(L, i - 1) * f(i, mid - 1);
    LS %= 998244353;
  }
  for (int i = mid; i <= R; i++) {
    RS += f(mid + 1, i) * f(i + 1, R);
    RS %= 998244353;
  }
  ret = LS * RS % 998244353;
  return ret;
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d %*d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", &A[i]);
  for (int i = 1; i <= N; i++) {
    int mn = 1234567890, idx = -1;
    for (int j = i; j <= N; j++) {
      if (mn > A[j]) mn = A[j], idx = j;
      B[i][j] = idx;
    }
  }
  printf("%lld", f(1, N));
  return 0;
}
