#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
struct Node {
  int l, r;
} q[500010];
map<int, int> Vis;
int ans, cnt, a[500010], vis[500010], flag[500010];
bool mycmp(Node x, Node y) { return x.l < y.l; }
inline int mul(int x, int y) { return 1LL * x * y % mod; }
inline int power(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1) ret = mul(ret, x);
    x = mul(x, x);
    y >>= 1;
  }
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) {
    if (!Vis[a[i]])
      Vis[a[i]] = i;
    else
      q[++cnt].l = Vis[a[i]], q[cnt].r = i, Vis[a[i]] = i;
  }
  sort(q + 1, q + cnt + 1, mycmp);
  for (int i = 2; i <= cnt; ++i)
    if (q[i - 1].r >= q[i].l)
      q[i].l = q[i - 1].l, q[i].r = max(q[i].r, q[i - 1].r), flag[i - 1] = 1;
  for (int i = 1; i <= cnt; ++i)
    if (!flag[i]) {
      if (q[i].l != 1) ++ans;
      for (int j = q[i].l; j <= q[i].r; ++j) vis[j] = 1;
    }
  for (int i = 2; i <= n; ++i)
    if (!vis[i]) ++ans;
  printf("%d\n", power(2, ans));
  return 0;
}
