#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, a[maxn];
const int mod = 998244353;
int sum[maxn], nex[maxn];
map<int, int> mmap, mmap1;
void enter() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (mmap[a[i]] == 0) mmap[a[i]] = i;
  }
  for (int i = n; i >= 1; --i) {
    if (mmap1[a[i]] == 0) mmap1[a[i]] = i;
  }
  vector<pair<int, int>> v;
  for (auto c : mmap)
    if (mmap1[c.first] != c.second) {
      nex[c.second] = mmap1[c.first];
      v.push_back(make_pair(c.second, mmap1[c.first]));
    }
  int pre = 0;
  int last = 0;
  sort(v.begin(), v.end());
  int cnt = 0;
  v.push_back(make_pair(n + 1, n + 1));
  for (auto c : v) {
    if (pre > c.first)
      pre = max(pre, c.second);
    else {
      if (last) {
        sum[last]++;
        sum[pre + 1]--;
      }
      last = c.first;
      if (last != n + 1) ++cnt;
      pre = c.second;
    }
  }
  for (int i = 1; i <= n; ++i) sum[i] += sum[i - 1];
  for (int i = 1; i <= n; ++i) {
    if (sum[i] == 0) cnt++;
  }
  int res = 1;
  for (int i = 1; i < cnt; ++i) res = (long long)res * 2 % mod;
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if (fopen("TEST"
            ".INP",
            "r"))
    freopen(
        "TEST"
        ".INP",
        "r", stdin),
        freopen(
            "TEST"
            ".OUT",
            "w", stdout);
  enter();
}
