#include <bits/stdc++.h>
using namespace std;
int modpow(int p, int n) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return modpow(((long long)p * p) % 998244353, n / 2);
  else
    return ((long long)p * modpow(((long long)p * p) % 998244353, n / 2)) %
           998244353;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int *a = new int[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  map<int, pair<int, int> > m;
  for (int i = 0; i < n; i++) {
    m[a[i]].first = INT_MAX;
    m[a[i]].second = INT_MIN;
  }
  for (int i = 0; i < n; i++) {
    m[a[i]].first = min(i, m[a[i]].first);
    m[a[i]].second = max(i, m[a[i]].second);
  }
  int cnt = 0;
  int temp = -1;
  for (int i = 0; i < n; i++) {
    if (temp < i) cnt++;
    temp = max(temp, m[a[i]].second);
  }
  cout << modpow(2, cnt - 1);
  delete[] a;
  return 0;
}
