#include <bits/stdc++.h>
using namespace std;
void deb(istream_iterator<string> it) { cout << endl; }
template <typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ",   ";
  deb(++it, args...);
}
const int mod = 998244353;
const int mxn = 3e5 + 9;
const long double eps = 1e-9;
long long bigmod(long long a, long long b) {
  if (b == 0) return 1 % mod;
  long long x = bigmod(a, b / 2);
  x = (x * x) % mod;
  if (b % 2 == 1) x = (x * a) % mod;
  return x;
}
long long n, k, m, ans = 0, value = 0;
long long a[mxn], b[mxn];
map<long long, vector<long long> > mp;
int fillup(int id) {
  vector<long long> v;
  long long last = mp[a[id]][mp[a[id]].size() - 1];
  for (int i = id; i <= last; i++) {
    last = max(last, mp[a[i]][mp[a[i]].size() - 1]);
    b[i] = value;
  }
  return last;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mp[a[i]].push_back(i);
  }
  memset(b, -1, sizeof(b));
  for (int i = 1; i <= n; i++) {
    int x = fillup(i);
    if (x >= n) break;
    value++;
    i = x;
  }
  cout << bigmod(2, value) << "\n";
  return 0;
}
