#include <bits/stdc++.h>
using namespace std;
int a[200010], Li[200010];
struct node {
  int L, R;
} b[200010];
int cmp(const node &a, const node &b) {
  if (a.L != b.L)
    return a.L < b.L;
  else
    return a.R < b.R;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), Li[i] = a[i];
  sort(Li + 1, Li + n + 1);
  int m = unique(Li + 1, Li + n + 1) - Li - 1;
  for (int i = 1; i <= n; ++i)
    a[i] = lower_bound(Li + 1, Li + m + 1, a[i]) - Li;
  for (int i = 1; i <= n; ++i) {
    int x = a[i];
    if (!b[x].L) b[x].L = i;
    b[x].R = i;
  }
  sort(b + 1, b + m + 1, cmp);
  int lim = 0, s = 0;
  for (int i = 1; i <= m; ++i) {
    if (b[i].L > lim)
      ++s, lim = b[i].R;
    else
      lim = max(lim, b[i].R);
  }
  int res = 1;
  for (int i = 1; i < s; ++i) res += res, res %= 998244353;
  cout << res;
}
