#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0)
    return (power(a, b / 2) * power(a, b / 2)) % 998244353;
  else
    return (a * power(a, b / 2) * power(a, b / 2)) % 998244353;
}
int main() {
  long long n, num, ma, cnt = 0;
  map<long long, pair<long long, long long> > mp;
  vector<pair<long long, long long> > v;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> num;
    if (mp[num].first == 0) mp[num].first = i;
    mp[num].second = i;
  }
  for (auto it = mp.begin(); it != mp.end(); it++)
    v.push_back({it->second.first, it->second.second});
  sort(v.begin(), v.end());
  ma = v[0].second;
  for (long long i = 1; i < v.size(); i++) {
    if (v[i].first > ma) {
      cnt++;
      ma = v[i].second;
    } else
      ma = max(ma, v[i].second);
  }
  cout << power(2, cnt);
}
