#include <bits/stdc++.h>
using namespace std;
char buffer[100000], *p1, *p2;
template <class T>
void read(T& x) {
  char ch = ((p1 == p2 &&
              (p2 = (p1 = buffer) + fread(buffer, 1, 100000, stdin), p1 == p2))
                 ? EOF
                 : *p1++);
  x = 0;
  bool f = 1;
  while (!('0' <= ch && ch <= '9') && ch != '-')
    ch = ((p1 == p2 &&
           (p2 = (p1 = buffer) + fread(buffer, 1, 100000, stdin), p1 == p2))
              ? EOF
              : *p1++);
  if (ch == '-')
    f = 0,
    ch = ((p1 == p2 &&
           (p2 = (p1 = buffer) + fread(buffer, 1, 100000, stdin), p1 == p2))
              ? EOF
              : *p1++);
  while ('0' <= ch && ch <= '9')
    x = (x << 1) + (x << 3) + ch - '0',
    ch = ((p1 == p2 &&
           (p2 = (p1 = buffer) + fread(buffer, 1, 100000, stdin), p1 == p2))
              ? EOF
              : *p1++);
  x = (f) ? x : -x;
}
int n, m;
int a[605];
bool vis[605][605];
int dp[605][605];
int DP(int l, int r) {
  if (l >= r) return 1;
  if (vis[l][r]) return dp[l][r];
  vis[l][r] = 1;
  int& ans = dp[l][r];
  int mi = n + 1, mip = -1;
  for (register int i = l; i <= r; i++)
    if (mi > a[i]) mi = a[i], mip = i;
  int le = 0, ri = 0;
  for (register int i = l - 1; i < mip; i++)
    le += (long long int)DP(l, i) * DP(i + 1, mip - 1) % 998244353,
        le %= 998244353;
  for (register int i = r + 1; i > mip; i--)
    ri += (long long int)DP(i, r) * DP(mip + 1, i - 1) % 998244353,
        ri %= 998244353;
  return ans = (long long int)le * ri % 998244353;
}
int main() {
  read(n), read(m);
  for (register int i = 1; i <= n; i++) read(a[i]);
  printf("%d", DP(1, n));
  return 0;
}
