#include <bits/stdc++.h>
using namespace std;
string s;
long long n, ans;
int main() {
  cin >> n;
  vector<long long> v(n);
  map<long long, long long> Map;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    Map[v[i]] = i;
  }
  long long ans = 1;
  long long i = 0;
  long long f = Map[v[i]];
  long long j = 0;
  while (j < n) {
    while (j < f && j < n) {
      f = max(Map[v[j]], f);
      j++;
    }
    j++;
    if (j >= n) break;
    f = Map[v[j]];
    ans = (ans * 2) % 998244353;
  }
  cout << ans;
}
