#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const long long mod = 998244353;
struct ss {
  int x, y;
  ss() { x = y = 0; }
} a[maxn], b[maxn];
bool cmp(const ss &p, const ss &q) {
  if (p.x == q.x) return p.y < q.y;
  return p.x < q.x;
}
map<int, int> ma;
long long qpow(long long x, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans = ans * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return ans;
}
int main() {
  int n, x;
  scanf("%d", &n);
  int t = 1;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    if (!ma[x]) {
      ma[x] = t++;
      a[ma[x]].x = i;
    }
    a[ma[x]].y = i;
  }
  sort(a + 1, a + t, cmp);
  long long ans = 1;
  int r = 1;
  for (int i = 1; i < t; ++i) {
    if (a[i].x > r) ans = ans * 2 % mod;
    r = max(r, a[i].y);
  }
  printf("%lld\n", ans);
  return 0;
}
