#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, -1, 0, 1, -1, 0, 1};
int kx8[] = {1, 1, 2, 2, -1, -1, -2, -2};
int ky8[] = {2, -2, 1, -1, 2, -2, 1, -1};
map<long long, long long> mp, vis;
long long a[100005 * 2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  long long res = 1, cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (cnt == 0 && i > 1) {
      res *= 2LL;
      res %= 998244353;
    }
    if (mp[a[i]] > 1 && !vis[a[i]]) {
      vis[a[i]] = 1;
      cnt++;
    }
    if (vis[a[i]]) {
      mp[a[i]]--;
    }
    if (mp[a[i]] == 0) cnt--;
  }
  cout << res << endl;
  return 0;
}
