#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return (b ? gcd(b, a % b) : a);
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
const long long int M = 998244353;
void solve() {
  long long int n;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  long long int suffix[n];
  map<long long int, long long int> m;
  for (long long int i = n - 1; i >= 0; i--) {
    if (m.find(a[i]) == m.end()) {
      m[a[i]] = i;
    }
    suffix[i] = m[a[i]];
  }
  long long int maxi = 0;
  long long int cnt = 0;
  for (long long int i = 0; i < n - 1; i++) {
    maxi = max(maxi, suffix[i]);
    if (maxi == i) cnt++;
  }
  cout << power(2, cnt, M) << endl;
}
int32_t main() {
  ios_base ::sync_with_stdio(false), cin.tie(NULL);
  solve();
  return 0;
}
