#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int N = 200006;
int a[N];
int mx[N];
int main() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  for (int i = 1; i <= n; ++i) {
    a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
  }
  for (int i = 1; i <= n; ++i) {
    mx[a[i]] = max(mx[a[i]], i);
  }
  int ans = 0;
  int ptr = 0;
  for (int i = 1; i <= n; ++i) {
    if (i > ptr) {
      ++ans;
      ptr = mx[a[i]];
    }
    ptr = max(ptr, mx[a[i]]);
  }
  --ans;
  long long rans = 1;
  while (ans--) {
    rans *= 2;
    rans %= mod;
  }
  cout << rans << endl;
}
