#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> elements;
  map<int, int> max_positions;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (max_positions[a] < i) {
      max_positions[a] = i;
    }
    elements.push_back(a);
  }
  int count = 1;
  int current_max = -1;
  for (int i = 0; i < n - 1; i++) {
    current_max = max(current_max, max_positions[elements[i]]);
    if (current_max == i) {
      count = (2 * count) % 998244353;
    }
  }
  cout << count << endl;
  return 0;
}
