#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e5 + 3;
const long long INF = 0x3f3f3f3f;
const long long MOD = 998244353;
long long arr[MAXN];
long long brr[MAXN];
long long initarr[MAXN];
long long dis[MAXN];
long long ans = 1;
long long solve(long long st) {
  long long max_elem = -INF;
  if (st) ans = (ans * 2LL) % MOD;
  long long ed = dis[brr[st]];
  for (long long i = st; i <= ed; ++i) {
    max_elem = max(max_elem, dis[brr[i]]);
    if (max_elem > ed) ed = max_elem;
  }
  return max_elem;
}
signed main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = 0; i < n; ++i) {
    scanf("%lld", &arr[i]);
    initarr[i] = arr[i];
  }
  sort(arr, arr + n);
  for (long long i = 0; i < n; ++i) {
    brr[i] = lower_bound(arr, arr + n, initarr[i]) - arr;
  }
  for (long long i = 0; i < n; ++i) {
    dis[brr[i]] = i;
  }
  long long st = 0;
  while (st < n) {
    st = solve(st);
    st++;
  }
  printf("%lld\n", ans);
  return 0;
}
