#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  int n;
  cin >> n;
  auto a = vector<int>(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  map<int, int> last;
  last[a[0]] = 0;
  vector<pair<int, int>> events;
  events.emplace_back(n, 0);
  events.emplace_back(n, 1);
  for (int i = 1; i < n; ++i) {
    if (last.count(a[i]) > 0) {
      events.emplace_back(last[a[i]] + 1, 0);
      events.emplace_back(i, 1);
    }
    last[a[i]] = i;
  }
  sort((events).begin(), (events).end());
  long long result = 1;
  auto active = 0;
  auto last_active = 0;
  for (auto& e : events) {
    if (e.second == 0) {
      if (active == 0) {
        for (int i = 0; i < (e.first - last_active - 1); ++i)
          result = result * 2 % 998244353;
      }
      active++;
    } else {
      active--;
      if (active == 0) last_active = e.first;
    }
  }
  cout << result << '\n';
  return 0;
}
