#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
const int mod = 998244353;
int a[N], t[N], pos[N];
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i], t[i] = a[i];
  sort(t + 1, t + 1 + n);
  int sz = unique(t + 1, t + 1 + n) - t - 1;
  for (int i = 1; i <= n; i++) a[i] = lower_bound(t + 1, t + 1 + sz, a[i]) - t;
  for (int i = 1; i <= n; i++) pos[a[i]] = i;
  int now = 1, p = 0;
  for (int i = 1; i <= n; i++) {
    if (i > now) p++;
    now = max(now, pos[a[i]]);
  }
  long long ans = powmod(2, 1ll * p);
  cout << ans << endl;
}
