#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long p = 998244353;
int a[N];
set<int> used;
bool l[N], r[N];
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    l[i] = r[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    if (!used.count(a[i])) {
      used.insert(a[i]);
      l[i] = 1;
    }
  }
  used.clear();
  for (int i = n; i >= 1; i--) {
    if (!used.count(a[i])) {
      used.insert(a[i]);
      r[i] = 1;
    }
  }
  int blocks = 0, cur = 0;
  for (int i = 1; i <= n; i++) {
    if (l[i]) cur++;
    if (r[i]) cur--;
    if (cur == 0) blocks++;
  }
  long long ans = binpow(2, blocks - 1);
  cout << ans << "\n";
  return 0;
}
