#include <bits/stdc++.h>
using namespace std;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1 << 29;
const long long INFL = 1LL << 60;
const long long mod = 998244353;
long long pow_mod(long long n, long long k, long long m) {
  long long r = 1;
  for (; k > 0; k >>= 1) {
    if (k & 1) r = (r * n) % m;
    n = (n * n) % m;
  }
  return r;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < int(n); i++) cin >> v[i];
  map<int, int> m;
  for (int i = 0; i < int(n); i++) {
    m[v[i]] = max(m[v[i]], i);
  }
  int cnt = -1;
  int p = -1;
  for (int i = 0; i < int(n); i++) {
    if (i == p + 1) {
      cnt++;
      p = m[v[i]];
    } else
      p = max(m[v[i]], p);
  }
  cout << pow_mod(2, cnt, mod) << endl;
  return 0;
}
