#include <bits/stdc++.h>
using namespace std;
int a[202020];
map<int, int> fr, to;
int main() {
  int n, ans = 1, m = 0, x = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (!fr.count(a[i])) fr[a[i]] = i;
    to[a[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    x += (fr[a[i]] == i);
    x -= (to[a[i]] == i);
    m += (x == 0);
  }
  while (--m) {
    ans = (ans * 2) % 998244353;
  }
  cout << ans << endl;
  return 0;
}
