#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int main() {
  int n;
  scanf("%d", &n);
  int arr[n + 5];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    mp[arr[i]] = i;
  }
  int pos = mp[arr[1]];
  for (int i = 1; i <= pos; i++) {
    pos = max(pos, mp[arr[i]]);
  }
  int ans = 1;
  for (int i = pos + 1; i <= n; i = pos + 1) {
    pos = mp[arr[i]];
    for (int j = i; j <= pos; j++) {
      pos = max(pos, mp[arr[j]]);
    }
    ans = ((ans % 998244353) * (2 % 998244353)) % 998244353;
  }
  printf("%d\n", ans);
  return 0;
}
