#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MAX = (int)(2e5) + 7;
const ll MOD = (ll)998244353;
const int INF_I = (int)(1e9) + 7;
const ll INF_LL = (ll)(1e18);
template <typename T>
void info(T& v) {
  for (const auto& i : v) cout << i << ' ';
  cout << endl;
}
template <typename T>
bool chkmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chkmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void boot_up() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(false);
}
struct event {
  int x;
  int type;
  event(int _x, int _type) {
    x = _x;
    type = _type;
  }
  bool operator<(const event& other) { return x < other.x; }
};
int n;
vector<int> a;
void solve();
signed main() {
  boot_up();
  while (cin >> n) solve();
}
void solve() {
  map<int, pair<int, int> > beg_end;
  a.assign(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (beg_end[a[i]].first == 0) {
      beg_end[a[i]].first = i;
      beg_end[a[i]].second = i;
    } else {
      beg_end[a[i]].second = i;
    }
  }
  int deg = -1;
  int opened = 0;
  for (int i = 1; i <= n; ++i) {
    if (beg_end[a[i]].first == i) {
      ++opened;
    }
    if (beg_end[a[i]].second == i) {
      --opened;
      if (!opened) {
        ++deg;
      }
    }
  }
  ll ans = 1;
  for (int i = 0; i < deg; ++i) {
    ans = (ans * 2LL) % MOD;
  }
  cout << ans % MOD << '\n';
}
