#include <bits/stdc++.h>
using namespace std;
map<int, int> first, last;
int n;
int x;
long long ans = 1;
vector<pair<int, int> > interval;
vector<pair<pair<int, int>, bool> > elem;
set<int> val;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (first.find(x) == first.end()) first[x] = i;
    last[x] = i;
  }
  for (map<int, int>::iterator it = first.begin(); it != first.end(); it++) {
    if (it->second == last[it->first]) continue;
    interval.push_back({it->second, last[it->first]});
  }
  for (int i = 0; i < interval.size(); i++) {
    elem.push_back({{interval[i].first, i}, 0});
    elem.push_back({{interval[i].second, i}, 1});
  }
  sort(elem.begin(), elem.end());
  int where = 0;
  for (int i = 1; i <= n; i++) {
    if (where == elem.size() && i != 1) {
      ans = (ans * 2LL) % 998244353;
      continue;
    }
    if (val.empty() && i != 1) ans = (ans * 2LL) % 998244353;
    if (where != elem.size() && elem[where].first.first == i) {
      if (elem[where].second == 0)
        val.insert(elem[where].first.second);
      else
        val.erase(elem[where].first.second);
      where++;
    }
  }
  cout << ans;
  return 0;
}
