#include <bits/stdc++.h>
using namespace std;
long long int mod = 998244353;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int dp[n + 5], a[n + 5];
  map<long long int, long long int> mp;
  for (long long int i = 0; i < n; i++) cin >> a[i], mp[a[i]] = i;
  long long int ans = 1;
  for (long long int i = 0; i < n; i++) {
    long long int mx = mp[a[i]];
    for (long long int j = i; j <= mx; j++) mx = max(mx, mp[a[j]]);
    i = mx;
    if (i != n - 1) ans = (ans * 2) % mod;
  }
  cout << ans;
  cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}
