#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-13;
const long double PI = acos(-1);
const int INF = (int)1e9;
const long long INFF = (long long)1e18;
const int mod = 998244353;
const int MXN = (int)1e6 + 7;
inline long long add(long long v1, long long v2) {
  v1 += v2;
  if (v1 >= mod) v1 -= mod;
  if (v1 < 0) v1 += mod;
  return v1;
}
int a[MXN];
pair<int, int> st[MXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  vector<int> buf(n);
  for (int i = 1; i <= n; i++) buf[i - 1] = a[i];
  sort(begin(buf), end(buf));
  buf.resize(unique(begin(buf), end(buf)) - buf.begin());
  for (int i = 1; i <= n; i++) {
    int p = lower_bound(begin(buf), end(buf), a[i]) - buf.begin();
    if (!st[p].first) st[p].first = i;
    st[p].second = i;
  }
  vector<pair<int, int> > seg;
  for (int i = 0; i < (int)(buf).size(); i++) {
    seg.push_back(st[i]);
  }
  sort(begin(seg), end(seg));
  int num = 0;
  for (int i = 0; i < (int)(seg).size(); i++) {
    int rr = seg[i].second, r = i;
    while (r + 1 < (int)(seg).size() && seg[r + 1].first < rr) {
      r++;
      rr = max(rr, seg[r].second);
    }
    i = r;
    num++;
  }
  num -= 1;
  int ans = 1;
  while (num--) ans = ans * 2 % mod;
  printf("%d\n", ans);
  return 0;
}
