#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  long long a[n];
  map<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]] = i;
  }
  long long ans = 1;
  long long maxidx;
  long long i = 0;
  maxidx = m[a[0]];
  for (long long j = 0; j <= maxidx; j++) {
    maxidx = max(maxidx, m[a[j]]);
  }
  i = maxidx + 1;
  while (i < n) {
    maxidx = m[a[i]];
    for (long long j = i; j <= maxidx; j++) {
      maxidx = max(maxidx, m[a[j]]);
    }
    i = maxidx + 1;
    ans = ((ans % 998244353) * 2) % 998244353;
  }
  cout << ans % 998244353;
}
