#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ar[n + 1];
  map<int, pair<int, int>> mp;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i];
    if (mp[ar[i]] == make_pair(0, 0)) {
      mp[ar[i]] = {i, i};
    } else {
      mp[ar[i]].second = i;
    }
  }
  pair<int, int> st;
  st = mp[ar[1]];
  mp[ar[1]] = {0, 0};
  int pow = 0;
  for (int i = 2; i <= n; i++) {
    if (mp[ar[i]] != make_pair(0, 0)) {
      if (st.second < i) {
        pow += i - st.second;
        st = mp[ar[i]];
      } else {
        st.second = max(st.second, mp[ar[i]].second);
      }
      mp[ar[i]] = {0, 0};
    }
  }
  int tm = 1;
  for (int i = 0; i < pow; i++) tm = tm * 2 % 998244353;
  cout << tm << endl;
}
