#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const double EPS = 1e-9;
const long long INF = 1e18 + 2007;
const double PI = 3.1415926535897932384626433832795;
const long long N = 200005;
const long long ALPHABET_SZ = 26;
vector<long long> v;
map<long long, long long> mp, mp2;
set<long long> st;
long long mod = 998244353;
long long binpow(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 1)
    return (binpow(a, n - 1) * a) % mod;
  else {
    long long b = binpow(a, n / 2);
    return (b * b) % mod;
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  long long n;
  cin >> n;
  v.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    mp[v[i]]++;
  }
  long long k = 0;
  for (long long i = 0; i < n; i++) {
    mp2[v[i]]++;
    if (mp2[v[i]] == mp[v[i]]) {
      st.erase(v[i]);
    } else {
      st.insert(v[i]);
    }
    if (st.empty()) {
      k++;
    }
  }
  cout << binpow(2, k - 1);
  return 0;
}
