#include <bits/stdc++.h>
using namespace std;
const int maxn = 200007;
const int mod = 998244353;
int a[maxn], len, vis[maxn];
struct line {
  int l, r;
  void input(int l1, int r1) {
    l = l1;
    r = r1;
  }
  bool operator<(line a1) const {
    if (l == a1.l) return r < a1.r;
    return l < a1.l;
  }
} l[maxn];
map<int, int> e, z;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++)
    if (!e[a[i]])
      z[a[i]] = e[a[i]] = i;
    else
      z[a[i]] = i;
  for (int i = 1; i <= n; i++) {
    if (e[a[i]] == i) l[++len].input(e[a[i]], z[a[i]]);
  }
  sort(l + 1, l + len + 1);
  int m = 1;
  int ans = 0;
  for (int i = 1; i <= len; i++) {
    ans += max(0, l[i].l - m);
    m = max(m, l[i].r);
  }
  long long u = 1, v = 2;
  while (ans) {
    if (ans & 1) u = (u * v) % mod;
    v = (v * v) % mod;
    ans >>= 1;
  }
  printf("%lld", u);
  return 0;
}
