#include <bits/stdc++.h>
using namespace std;
const long long int rng = 200005;
long long int arr[rng];
const long long int mod = 998244353;
map<long long int, vector<long long int>> mp;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    mp[arr[i]].push_back(i);
  }
  long long int total_num = -1;
  for (long long int i = 0; i < n; i++) {
    long long int lo = n, hi = -1;
    if (mp[arr[i]].size() > 1) {
      int j = i;
      while (j != hi && j < n) {
        if (mp[arr[j]].size() > 1) {
          lo = min(lo, mp[arr[j]][0]);
          hi = max(hi, mp[arr[j]][mp[arr[j]].size() - 1]);
        }
        j++;
      }
      i = j;
    }
    total_num++;
  }
  long long int Ans = 1;
  while (total_num--) {
    Ans *= 2LL;
    Ans %= mod;
  }
  cout << Ans % mod << endl;
  return 0;
}
