#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, MOD = 998244353;
int n, a[N];
map<int, int> lastOcc;
int r[N];
int bigmod(int a, int e, int m) {
  if (e == -1) e = m - 2;
  int r = 1;
  while (e) {
    if (e & 1) {
      r = ((long long)r * a) % m;
      e--;
    }
    a = ((long long)a * a) % m;
    e /= 2;
  }
  return r;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (lastOcc[a[i]]) r[lastOcc[a[i]]] = i;
    lastOcc[a[i]] = i;
  }
  int flexCnt = 0;
  int endAt = r[1];
  for (int i = 2; i <= n; i++) {
    if (endAt < i) flexCnt++;
    endAt = max(endAt, r[i]);
  }
  cout << bigmod(2, flexCnt, MOD) << endl;
  return 0;
}
