#include <bits/stdc++.h>
using namespace std;
int ch[200001];
map<int, set<int>> m;
map<int, int> ma;
int ans = 1;
int j = 0;
void upd() {
  int u = j;
  while (1) {
    int r = 0;
    for (int i = j; i >= u; --i) {
      r = max(r, (*(--(m[ma[i]].end()))));
    }
    if (j == r) break;
    u = j + 1;
    j = r;
  }
  ++j;
}
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ma[i] = a[i];
    m[a[i]].insert(i);
  }
  int mo = 998244353;
  ans = 1;
  while (j < n) {
    upd();
    if (j >= n) break;
    ans *= 2;
    ans %= mo;
  }
  cout << ans % mo;
}
