#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y % 2 == 1) res = (res * x) % p;
    y = y / 2;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(20);
  long long int mod = 998244353;
  long long int n, lasti;
  map<long long int, long long int> make_pair;
  cin >> n;
  long long int a[n];
  int cur = 1, curi = 0;
  for (int i = (0), i_end_ = (n); i < i_end_; ++i) {
    cin >> a[i];
    make_pair[a[i]] = i;
  }
  for (int i = (0), i_end_ = (n); i < i_end_; ++i) {
    if (i > curi) cur++;
    lasti = make_pair[a[i]];
    if (lasti > curi) curi = lasti;
  }
  cout << power((long long int)2, (cur - 1), mod);
  return 0;
}
