#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int maxn = 212345;
int n, a[maxn], f[maxn], pre[maxn];
vector<int> b;
int F(int x) { return x == f[x] ? x : f[x] = F(f[x]); }
inline void U(int a, int b) { f[min(F(a), F(b))] = max(F(a), F(b)); }
inline void go(int l, int r) {
  for (int i = l, j;; i = j) {
    j = F(i) + 1;
    if (j > r) return;
    U(i, j);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) b.push_back(a[i]);
  for (int i = 1; i <= n; ++i) f[i] = i;
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  for (int i = 1; i <= n; ++i)
    a[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
  for (int i = 1; i <= n; ++i) {
    if (pre[a[i]]) go(pre[a[i]], i);
    pre[a[i]] = i;
  }
  long long res = 1, cnt = 0;
  for (int i = 1; i <= n; ++i)
    if (F(i) == i) {
      if (cnt) res = (res + res) % mod;
      ++cnt;
    }
  cout << res << endl;
  return 0;
}
