#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, t, k, n, m, l, b, f, st;
  cin >> n;
  long long int a[n];
  for (i = 0; i < n; ++i) cin >> a[i];
  map<long long int, long long int> mp;
  for (i = 0; i < n; ++i) mp[a[i]] = max(mp[a[i]], i);
  f = 0;
  st = -1;
  for (i = 0; i < n; ++i) {
    if (i < st) {
      st = max(st, mp[a[i]]);
      continue;
    }
    if (mp[a[i]] > st) {
      f++;
      st = mp[a[i]];
    }
  }
  long long int ans = 1;
  for (i = 0; i < f - 1; ++i) ans = (ans * 2) % 998244353;
  cout << ans << "\n";
  return 0;
}
