#include <bits/stdc++.h>
using namespace std;
int n;
int pre[200010];
map<int, int> mini;
map<int, int> maxi;
set<int> s;
const long long mod = 998244353;
long long pow(long long x) {
  if (!x) return 1;
  long long ret = pow(x / 2);
  ret = ret * ret % mod;
  if (x % 2) ret = ret * 2 % mod;
  return ret;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    s.insert(x);
    if (mini.count(x)) {
      mini[x] = min(mini[x], i);
      maxi[x] = max(maxi[x], i);
    } else {
      mini[x] = i;
      maxi[x] = i;
    }
  }
  for (auto x = s.begin(); x != s.end(); x++) {
    int t = *x;
    if (mini[t] != maxi[t]) {
      pre[mini[t] + 1]++;
      pre[maxi[t] + 1]--;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + pre[i];
    if (i > 1 && !pre[i]) cnt++;
  }
  cout << pow(cnt) << endl;
}
