#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MOD = 998244353;
const int MAXN = 1e6 + 3;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> a(n + 1);
  map<long long, long long> last;
  for (long long i = 1; i <= (n); ++i) {
    cin >> a[i];
    last[a[i]] = i;
  }
  long long ans = 1;
  for (long long i = 1; i <= (n); ++i) {
    if (i > 1) {
      ans = 2 * ans;
      ans %= MOD;
    }
    long long cur = last[a[i]];
    long long idx = i + 1;
    while (idx <= cur) {
      cur = max(cur, last[a[idx]]);
      idx++;
    }
    i = cur;
  }
  cout << ans << '\n';
  return 0;
}
