#include <bits/stdc++.h>
using namespace std;
long long INF = 1 << 15;
long long n;
struct no {
  long long x, y, z;
};
no a[200100];
struct node {
  int begin, end;
};
node b[200100];
int cmp(const no& c, const no& d) {
  if (c.x == d.x) return c.z < d.z;
  return c.x < d.x;
}
int cmp1(const node& c, const node& d) { return c.begin < d.begin; }
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].x;
    a[i].z = i + 1;
  }
  sort(a, a + n, cmp);
  int r = 0;
  b[r].begin = a[0].z;
  for (int i = 1; i < n; i++) {
    if (a[i].x == a[i - 1].x) {
      b[r].end = a[i].z;
    } else {
      b[r].end = a[i - 1].z;
      r++;
      b[r].begin = a[i].z;
    }
  }
  if (b[r].end == 0) {
    b[r].end = a[n - 1].z;
  }
  sort(b, b + r + 1, cmp1);
  int res = 0;
  int un = b[0].begin, nm = b[0].end;
  for (int i = 1; i < r + 1; i++) {
    if (b[i].begin <= nm) {
      if (nm < b[i].end) nm = b[i].end;
    } else {
      nm = b[i].end;
      res++;
    }
  }
  long long res1 = 1;
  for (int i = 1; i <= res; i++) {
    res1 = (res1 * 2) % 998244353;
  }
  printf("%I64d", res1);
  return 0;
}
