#include <bits/stdc++.h>
using namespace std;
const int max_n = 2 * 1e5 + 1;
const long long mod = 998244353;
int n;
int a[max_n], segment[max_n];
map<long long, set<long long>> mp;
long long ans = 1;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    mp[a[i]].insert(i);
  }
  for (auto it : mp) {
    long long lf = *it.second.begin();
    long long rg = *prev(it.second.end());
    if (lf == rg) continue;
    segment[lf + 1]++;
    segment[rg + 1]--;
  }
  for (int i = 1; i <= n; i++) segment[i] += segment[i - 1];
  long long cur = 1;
  while (cur < n) {
    if (!segment[cur + 1]) {
      ans *= 2;
      ans %= mod;
    }
    cur++;
  }
  cout << ans;
}
