You are given an array $a$ consisting of $n$ integers. Let's denote monotonic renumeration of array $a$ as an array $b$ consisting of $n$ integers such that all of the following conditions are met:

  $b_1 = 0$;  for every pair of indices $i$ and $j$ such that $1 \le i, j \le n$, if $a_i = a_j$, then $b_i = b_j$ (note that if $a_i \ne a_j$, it is still possible that $b_i = b_j$);  for every index $i \in [1, n - 1]$ either $b_i = b_{i + 1}$ or $b_i + 1 = b_{i + 1}$. 

For example, if $a = [1, 2, 1, 2, 3]$, then two possible monotonic renumerations of $a$ are $b = [0, 0, 0, 0, 0]$ and $b = [0, 0, 0, 0, 1]$.

Your task is to calculate the number of different monotonic renumerations of $a$. The answer may be large, so print it modulo $998244353$.


-----Input-----

The first line contains one integer $n$ ($2 \le n \le 2 \cdot 10^5$) — the number of elements in $a$.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).


-----Output-----

Print one integer — the number of different monotonic renumerations of $a$, taken modulo $998244353$.


-----Examples-----
Input
5
1 2 1 2 3

Output
2

Input
2
100 1

Output
2

Input
4
1 3 3 7

Output
4

Difficulty: MEDIUM_HARD
Tags: Sorting

Combinatorics
Skill types: Sorting

Starter code:

Solutions:
mod = 998244353
n = int(input())
a = list(map(int, input().split()))
poses = dict()
for i in range(n):
	poses[a[i]] = i
ans = 1
pos = 0
while pos < n:
	need = poses[a[pos]]
	while pos < n and pos <= need:
		need = max(need, poses[a[pos]])
		pos += 1
	ans += 1
ans -= 1
answer = 1
for i in range(ans - 1):
	answer = answer * 2 % mod
print(answer)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	last_pos = {}
	for i in range(n):
		last_pos[a[i]] = i
	(ret, cur) = (1, -1)
	for i in range(n - 1):
		cur = max(cur, last_pos[a[i]])
		if cur == i:
			ret = ret * 2 % 998244353
	print(ret)
main()


from bisect import bisect_left
mod = 998244353
n = int(input())
a = [int(x) for x in input().split()]
s = sorted(a)
a = [bisect_left(s, x) for x in a]
(first, last) = ([n] * n, [-1] * n)
for i in range(n):
	first[a[n - 1 - i]] = n - 1 - i
	last[a[i]] = i
ans = 1
cur = last[a[0]]
for i in range(n):
	if first[a[i]] == i:
		if i > cur:
			ans <<= 1
			if ans > mod:
				ans -= mod
		cur = max(cur, last[a[i]])
print(ans)


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
import random

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	cnt = []
	while n % 2 == 0:
		cnt.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			cnt.append(i)
			n = n / i
	if n > 2:
		cnt.append(int(n))
	return cnt

def primeFactorsCount(n):
	cnt = 0
	while n % 2 == 0:
		cnt += 1
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			cnt += 1
			n = n // i
	if n > 2:
		cnt += 1
	return cnt

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	i = 2
	while i * i <= n:
		if primes[i] == True:
			for j in range(i * i, n + 1, i):
				primes[j] = False
		i += 1
	pr = []
	for i in range(0, n + 1):
		if primes[i]:
			pr.append(i)
	return pr

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s

def defaultDictDefaultVal():
	return -1
n = int(input())
l = list(map(int, input().split()))
pos = collections.defaultdict(defaultDictDefaultVal)
for i in range(0, n):
	pos[l[i]] = max(pos[l[i]], i)
seg = 0
lp = pos[l[0]]
for i in range(1, n):
	if i > lp:
		seg += 1
	lp = max(lp, pos[l[i]])
print(pow(2, seg, 998244353))


from sys import stdin
input = stdin.buffer.readline
mod = 998244353
n = int(input())
arr = [int(x) for x in input().split()]
d = {}
for i in range(n):
	if arr[i] in d:
		d[arr[i]].append(i)
	else:
		d[arr[i]] = [i]
i = 0
des = d[arr[0]][-1]
while i <= des:
	des = max(des, d[arr[i]][-1])
	i = i + 1
pos = i
ans = 1
start = pos
while start < n:
	i = start
	des = d[arr[start]][-1]
	while i <= des:
		des = max(des, d[arr[i]][-1])
		i = i + 1
	ans = ans * 2 % mod
	start = i
print(ans)


(s, l, k, r, rend, sp, lk, f) = ('', -1, 0, {}, {}, [], 0, 1)
d1 = d2 = 0
n = int(input())
a = tuple(map(int, input().split()))
for (key, val) in enumerate(a):
	if r.get(val) is None:
		r[val] = key
	else:
		rend[val] = key
for (key, value) in rend.items():
	sp.append([r.get(key), value])
sp.sort(key=lambda x: x[0])
if sp:
	(d1, d2) = (sp[0][0], sp[0][1])
for i in sp[1:]:
	if i[0] < d2 < i[1]:
		d2 = i[1]
	elif i[0] > d2:
		k += d2 - d1 + 1
		lk += 1
		d1 = i[0]
		d2 = i[1]
k += d2 - d1 + 1
for i in range(n - k + lk):
	f *= 2
	if f > 998244353:
		f += -998244353
print(f)


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 998244353
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():
	n = ii()
	a = li()
	m = {}
	for i in range(n):
		m[a[i]] = i
	r = 0
	k = -1
	for i in range(n):
		r = max(r, m[a[i]])
		if i == r:
			k += 1
	print(pow(2, k, mod))
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


(n, l) = (int(input()), list(map(int, input().split())))
d = {l[i]: i for i in range(n)}
m = d[l[0]]
a = 1
for i in range(1, n):
	if i > m:
		a = a * 2 % 998244353
	m = max(m, d[l[i]])
print(a)


import math
mod = 998244353
n = int(input())
arr = list(map(int, input().split()))
dict1 = {}
dict2 = {}
for i in range(len(arr)):
	try:
		dict1[arr[i]] += 1
		dict1[arr[i]] -= 1
		try:
			dict2[arr[i]][1] = i + 1
		except:
			KeyError
			dict2[arr[i]] = [dict1[arr[i]]]
			dict2[arr[i]].append(i + 1)
	except:
		KeyError
		dict1[arr[i]] = i + 1
arrx = []
for i in list(dict2.keys()):
	arrx.append((dict2[i][0], dict2[i][1]))
arrx.sort()
count = 0
indexes = 0
if len(arrx) == 0:
	print(pow(2, n - 1, mod))
else:
	flag = 0
	minval = arrx[0][0]
	maxval = arrx[0][1]
	if minval == 1:
		count = -1
		flag = 1
	indexes = maxval - minval + 1
	for i in range(1, len(arrx)):
		if arrx[i][0] > maxval:
			count += 1
			minval = arrx[i][0]
			maxval = arrx[i][1]
			indexes += maxval - minval + 1
		else:
			indexes += max(0, arrx[i][1] - maxval)
			maxval = max(maxval, arrx[i][1])
	count += 1
	rem = n - indexes
	if flag == 1:
		countx = count + rem
	else:
		countx = count + rem - 1
	print(pow(2, countx, mod))


n = int(input())
ar = list(map(int, input().split()))
d = dict()
for x in range(n):
	q = d.get(ar[x])
	if q:
		q[1] = x
	else:
		d[ar[x]] = [x, x]
q = [d[x] for x in d]
q.sort(key=lambda x: (x[0], x[1]))
s = set(range(len(q)))
for x in range(1, len(q)):
	if q[x][0] >= q[x - 1][0] and q[x][0] <= q[x - 1][1]:
		q[x][0] = q[x - 1][0]
		q[x][1] = max(q[x][1], q[x - 1][1])
		s.remove(x - 1)
f = []
for x in s:
	if q[x][0] != q[x][1]:
		f.append(q[x])
res = len(ar)
for x in f:
	res -= x[1] - x[0]
q = 1
for x in range(res - 1):
	q = q * 2 % 998244353
print(q)


import math
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
	if a[i] not in d:
		d[a[i]] = (i, i)
	else:
		t = d[a[i]]
		d[a[i]] = (min(t[0], i), max(t[1], i))
seg = sorted(d.values())
ans = 0
cur = (0, 0)
for s in seg:
	if s[0] <= cur[1]:
		cur = (cur[0], max(cur[1], s[1]))
	else:
		cur = s
		ans += 1
print(2 ** ans % 998244353)


n = int(input())
a = list(map(int, input().split()))
d = {}
for (i, v) in enumerate(a):
	d[v] = i
res = 1
r = 0
for t in range(n):
	if t > r:
		res *= 2
		res %= 998244353
	r = max(r, d[a[t]])
print(res)


mod = 998244353
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
	d[a[i]] = i
i = 1
ans = 1
d2 = {}
ma = d[a[0]]
d2[a[0]] = 1
while i < n:
	tmp = d[a[i]]
	if a[i] in d2:
		i += 1
	elif i > ma:
		ans = ans * 2 % mod
		d2[a[i]] = 1
	else:
		d2[a[i]] = 1
	ma = max(ma, tmp)
print(ans)


mod = 998244353
n = int(input())
dat = list(map(int, input().split()))
num_firstpos = dict()
num_lastpos = dict()
for i in range(n):
	num_lastpos[dat[i]] = i
	if dat[i] not in num_firstpos:
		num_firstpos[dat[i]] = i
res = 1
cur = 0
skipto = num_lastpos[dat[0]]
while cur < n - 1:
	cur += 1
	curval = dat[cur]
	if skipto <= cur:
		if num_firstpos[curval] == cur:
			res *= 2
			res %= mod
	skipto = max(skipto, num_lastpos[curval])
print(res)


n = int(input())
a = list((int(x) for x in input().split()))
r = {}
for i in range(n):
	r[a[i]] = i
maxRight = r[a[0]]
ans = 1
for i in range(n):
	if i > maxRight:
		ans = (ans << 1) % 998244353
	maxRight = max(r[a[i]], maxRight)
print(ans)


from collections import defaultdict
import sys

def input():
	return sys.stdin.readline().rstrip()
MOD = 998244353

def slv():
	n = int(input())
	a = list(map(int, input().split()))
	Group = set([])
	d = defaultdict(list)
	for (idx, v) in enumerate(a):
		d[v].append(idx)
	seen = [False] * n
	ans = 0.5
	for i in range(n):
		if not Group:
			ans = ans * 2
			ans = int(ans) % MOD
		if i in Group:
			Group.remove(i)
			continue
		else:
			v = a[i]
			for idx in d[v]:
				Group.add(idx)
			Group.remove(i)
	print(ans % MOD)
	return

def main():
	t = 1
	for i in range(t):
		slv()
	return
main()


import io
import os
from collections import defaultdict
from sys import stdin, stdout
from math import gcd

def main():
	n = int(input())
	a = list(map(int, input().split()))
	last = {}
	for (i, val) in enumerate(a):
		last[val] = i
	segments = 0
	pos = 0
	while pos < n:
		end = last[a[pos]]
		x = pos + 1
		while x <= end:
			end = max(end, last[a[x]])
			x += 1
		segments += 1
		pos = end + 1
	res = 1
	for i in range(segments - 1):
		res = res * 2 % 998244353
	print(res)
main()


def main():
	n = int(input())
	a = list(map(int, input().split()))
	dict_min = {}
	dict_max = {}
	for i in range(n):
		if a[i] not in dict_min:
			dict_min[a[i]] = i
	for i in range(n - 1, -1, -1):
		if a[i] not in dict_max:
			dict_max[a[i]] = i
	b = sorted(set(a))
	pos = -1
	c = []
	for num in b:
		c.append([dict_min[num], dict_max[num]])
	c.sort()
	ctr = 0
	for pair in c:
		l = pair[0]
		r = pair[1]
		if l > pos:
			ctr += 1
		pos = max(pos, r)
	ans = 1
	for i in range(0, ctr - 1):
		ans = ans * 2 % 998244353
	print(ans)
main()


from collections import defaultdict
n = int(input())
a = [int(x) for x in input().split()]
d = defaultdict(list)
for i in range(n):
	if a[i] not in d:
		d[a[i]] = [i, i]
	d[a[i]][1] = i
cmax = 0
num = -1
for i in range(n):
	if d[a[i]][1] > cmax:
		cmax = d[a[i]][1]
	if cmax == i:
		num += 1
print(pow(2, num, 998244353))


def read():
	return int(input())

def reads():
	return [int(x) for x in input().split()]
N = read()
A = reads()
H = {}
for i in range(N):
	H[A[i]] = i
num = 0
t = 0
i = 0
while i < N:
	t = H[A[i]]
	while i < t:
		if t < H[A[i]]:
			t = H[A[i]]
		i += 1
	num += 1
	i += 1
print(pow(2, num - 1, 998244353))


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	mod = 998244353
	nums = {}
	for i in range(n):
		nums[arr[i]] = i
	ans = 1
	max_last = nums[arr[0]]
	for i in range(n - 1):
		max_last = max(max_last, nums[arr[i]])
		if max_last == i:
			ans *= 2
		ans = ans % mod
	print(ans)
main()


from sys import exit
from collections import defaultdict, Counter
n = int(input())
vec = list(map(int, input().split()))
ans = 0
mp = defaultdict(list)
cnt = Counter(vec)
for i in range(n):
	mp[vec[i]].append(i)
i = 0
s = set(vec)
while i < n:
	cur = vec[i]
	l = int(mp[cur][-1])
	j = i
	while j < l:
		l = max(l, int(mp[vec[j]][-1]))
		j += 1
	ans += 1
	i = l + 1
print(pow(2, ans - 1, 998244353))


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
mod = 998244353
INIT = dict()
LAST = dict()
for i in range(n):
	if INIT.get(A[i]) == None:
		INIT[A[i]] = i
	LAST[A[i]] = i
ANS = 0
NOW = 0
i = 0
while i < n:
	NOW = LAST[A[i]]
	while i < n and i <= NOW:
		if LAST[A[i]] > NOW:
			NOW = LAST[A[i]]
		i += 1
	if i == n:
		break
	else:
		ANS += 1
print(pow(2, ANS, mod))


import collections
import time
import os
import sys
import bisect
import heapq

def pow2(n, mod):
	if n == 0:
		return 1
	if n == 1:
		return 2
	h = pow2(n // 2, mod)
	if n % 2 == 0:
		return h * h % mod
	else:
		return h * h * 2 % mod
MOD = 998244353
N = int(input())
A = [int(x) for x in input().split()]
(S, T) = ({}, {})
for (i, v) in enumerate(A):
	if v not in S:
		S[v] = i
	else:
		T[v] = i
segs = [(S[k], v) for (k, v) in T.items()]
segs.sort()
if not segs:
	print(pow2(N - 1, MOD))
else:
	i = 1
	(s, t) = segs[0]
	segCount = s
	while i < len(segs):
		seg = segs[i]
		if seg[0] <= t:
			t = max(t, seg[1])
		else:
			segCount += seg[0] - t
			(s, t) = seg
		i += 1
	segCount += N - t
	print(pow2(segCount - 1, MOD))


N = int(input())
arr = input()
arr = [int(x) for x in arr.split(' ')]
pos = {}
res = -1
for i in range(N):
	pos[arr[i]] = i
right = 0
for i in range(N):
	right = max(right, pos[arr[i]])
	if i == right:
		res += 1
s = 1
for i in range(res):
	s *= 2
	s = s % 998244353
print(s)


def read(type=1):
	if type:
		file = open('input.dat', 'r')
		n = int(file.readline())
		line = list(map(int, file.readline().split()))
		file.close()
	else:
		n = int(input().strip())
		line = list(map(int, input().strip().split()))
	return (n, line)

def solve():
	MOD = 998244353
	sol = 0.5
	ranges = {}
	pos = 0
	for v in a:
		if v not in ranges:
			ranges[v] = (pos, pos)
		else:
			ranges[v] = (ranges[v][0], pos)
		pos += 1
	pos = 0
	ranges = list(ranges.items())
	i = 0
	while pos < n:
		while 1:
			if ranges[i][1][0] <= pos:
				if ranges[i][1][1] > pos:
					pos = ranges[i][1][1]
				i += 1
				if i == len(ranges):
					break
			else:
				break
		sol = int(2 * sol)
		sol %= MOD
		pos += 1
	return sol
(n, a) = read(0)
sol = solve()
print(sol)


n = int(input())
a = list(map(int, input().split()))
mod = 998244353
d = {}
for i in range(n):
	d[int(a[i])] = i
ptr = 0
ans = 0
while ptr < n:
	seek = d.get(int(a[ptr]))
	while ptr < n and ptr <= seek:
		seek = max(seek, d.get(int(a[ptr])))
		ptr += 1
	ans += 1
print(pow(2, ans - 1, mod))


import os, sys, math
from io import BytesIO, IOBase
from collections import defaultdict, deque, OrderedDict
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

def I():
	return int(input())

def In():
	return map(int, input().split())

def ln():
	return list(map(int, input().split()))

def Sn():
	return input().strip()
BUFSIZE = 8192

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return len(a)

def solve():
	n = I()
	l = list(In())
	pos = {}
	for i in range(n - 1, -1, -1):
		if pos.get(l[i], -1) == -1:
			pos[l[i]] = i
	d = {l[0]: 1}
	mx = pos[l[0]]
	cnt = 1
	for i in range(n):
		if d.get(l[i], -1) != -1:
			cnt = d[l[i]]
			mx = max(mx, pos[l[i]])
		elif mx < i:
			cnt *= 2
			cnt %= M
			d[l[i]] = cnt
			mx = max(mx, pos[l[i]])
		else:
			mx = max(mx, pos[l[i]])
			d[l[i]] = cnt
	print(cnt % M)
	pass

def main():
	T = 1
	for i in range(T):
		solve()
M = 998244353
P = 1000000007

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import defaultdict
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
mod = 998244353
inf = 1145141919810
(l, r) = (defaultdict(lambda : inf), defaultdict(lambda : -inf))
for i in range(n):
	ai = a[i]
	l[ai] = min(l[ai], i)
	r[ai] = max(r[ai], i)
s = set(a)
m = len(s)
(l0, r0) = ([0] * n, [0] * n)
for i in s:
	l0[l[i]] = 1
	r0[r[i]] = 1
for i in range(n - 2, -1, -1):
	l0[i] += l0[i + 1]
for i in range(1, n):
	r0[i] += r0[i - 1]
d = 0
for i in range(n - 1):
	d += (l0[i + 1] + r0[i]) // m
ans = pow(2, d, mod)
print(ans)


def readline():
	return map(int, input().split())

def main():
	(n,) = readline()
	a = list(readline())
	first_occurence = dict()
	magic = list()
	for (i, ai) in enumerate(a):
		fst = first_occurence.setdefault(ai, i)
		if fst == i:
			magic.append(None)
		else:
			magic.append(i + 1)
			j = fst + 1
			while j < i:
				new_j = magic[j] or j + 1
				magic[j] = i + 1
				j = new_j
	print(pow(2, magic.count(None) - 1, 998244353))
main()


n = int(input())
a = []
a = input().split(' ')
a = [int(i) for i in a]

def calc():
	global a, n
	for i in range(len(a)):
		a[i] = [a[i], i]
	a = sorted(a)
	p = [a[0][1]]
	k = [a[-1][1]]
	for i in range(1, len(a)):
		if a[i - 1][0] != a[i][0]:
			p.append(a[i][1])
			k.append(a[i - 1][1])
	p = sorted(p)
	k = sorted(k)
	op = 0
	wsk1 = 0
	wsk2 = 0
	ile = 0
	for i in range(len(a)):
		if wsk1 < len(p) and p[wsk1] == i:
			op += 1
			wsk1 += 1
		if wsk2 < len(k) and k[wsk2] == i:
			op -= 1
			wsk2 += 1
		if op == 0:
			ile += 1
	return ile
print(2 ** (calc() - 1) % 998244353)


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
	n = int(stdin.readline())
	a = [int(x) for x in stdin.readline().split()]
	b = [2] * (n + 2)
	maxR = {}
	minL = {}
	for i in range(n):
		x = a[i]
		maxR[x] = i
		minL[x] = minL.get(x, i)
	f = [0] * (n + 2)
	for i in range(n):
		x = a[i]
		l = minL[x]
		r = maxR[x]
		if l < r:
			if r == l - 1:
				b[r] = 1
			else:
				f[l + 1] = f[l + 1] + 1
				f[r + 1] = f[r + 1] - 1
	res = 1
	for i in range(1, n):
		f[i] = f[i] + f[i - 1]
		if f[i] > 0:
			b[i] = 1
		res = res * b[i] % 998244353
	stdout.write(str(res))
	return 0
main()


from collections import defaultdict as dc
n = int(input())
a = list(map(int, input().split()))
cn = 1
m = 998244353
hsh = dc(int)
hsh2 = dc(int)
for i in a:
	hsh[i] += 1
sm = 0
for i in range(n - 1):
	if hsh2[a[i]]:
		sm -= 1
	else:
		sm += hsh[a[i]] - 1
	hsh2[a[i]] += 1
	if sm == 0:
		cn *= 2
		cn %= m
print(cn)


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
m = 998244353
b = {}
for i in range(n):
	b[a[i]] = i
ma = b[a[0]]
ans = 1
for i in range(1, n):
	if i > ma:
		ans = ans * 2 % m
	ma = max(ma, b[a[i]])
print(ans)


n = int(input())
a = list(map(int, input().split()))
ans = 0
end = {}
for (p, v) in enumerate(a):
	end[v] = p
visit = [False] * n
mod = 998244353
for i in range(n):
	if not visit[i]:
		if ans == 0:
			ans = 1
		else:
			ans = ans * 2 % mod
		last = end[a[i]]
		j = i
		while j <= last:
			visit[j] = True
			last = max(last, end[a[j]])
			j += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
m = 998244353
b = {}
for i in range(n):
	b[a[i]] = i
ma = b[a[0]]
ans = 1
for i in range(1, n):
	if i > ma:
		ans = ans * 2 % m
	ma = max(ma, b[a[i]])
print(ans)


n = int(input())
m = list(map(int, input().split()))
pre = {}
suf = {}
for (i, e) in enumerate(m):
	suf[e] = i
for (i, e) in enumerate(reversed(m)):
	pre[e] = n - i - 1
a = []
for i in set(m):
	a.append((pre[i], suf[i]))
b = []
for (begin, end) in sorted(a):
	if b and b[-1][1] > begin - 1:
		b[-1][1] = max(b[-1][1], end)
	else:
		b.append([begin, end])
print(2 ** (len(b) - 1) % 998244353)


n = int(input())
a = tuple(map(int, input().split()))
d = dict()
for i in range(n):
	if a[i] not in d:
		d[a[i]] = [i, i]
	else:
		d[a[i]][1] = i
cur = 0
num = -1
for i in range(n):
	if d[a[i]][1] > cur:
		cur = d[a[i]][1]
	if cur == i:
		num += 1
print(pow(2, num, 998244353))


from collections import *
n = int(input())
l = list(map(int, input().split()))
rng = defaultdict(lambda : [-1, -1])
for i in range(n):
	val = l[i]
	if rng[val][0] == -1:
		rng[val] = [i, i]
	else:
		rng[val][1] = i
currRng = -1
tot = 0
for (i, j) in sorted(rng.values()):
	if i > currRng:
		tot += 1
	currRng = max(currRng, j)
print(pow(2, tot - 1, 998244353))


class SegmentTree(object):
	__slots__ = ['elem_size', 'tree', 'default', 'op']

	def __init__(self, a: list, default: int, op):
		import math
		real_size = len(a)
		self.elem_size = elem_size = 1 << math.ceil(math.log(real_size, 2))
		self.tree = tree = [default] * (elem_size * 2)
		tree[elem_size:elem_size + real_size] = a
		self.default = default
		self.op = op
		for i in range(elem_size - 1, 0, -1):
			tree[i] = op(tree[i << 1], tree[(i << 1) + 1])

	def get_value(self, x: int, y: int) -> int:
		(l, r) = (x + self.elem_size, y + self.elem_size)
		(tree, result, op) = (self.tree, self.default, self.op)
		while l < r:
			if l & 1:
				result = op(tree[l], result)
				l += 1
			if r & 1:
				r -= 1
				result = op(tree[r], result)
			(l, r) = (l >> 1, r >> 1)
		return result

	def set_value(self, i: int, value: int) -> None:
		k = self.elem_size + i
		self.tree[k] = value
		self.update(k)

	def update(self, i: int) -> None:
		(op, tree) = (self.op, self.tree)
		while i > 1:
			i >>= 1
			tree[i] = op(tree[i << 1], tree[(i << 1) + 1])

def __starting_point():
	from collections import defaultdict
	N = int(input())
	a = list(map(int, input().split()))
	index_dict = defaultdict(list)
	for (i, n) in enumerate(a):
		index_dict[n].append(i)
	last_num = 0
	ans = []
	append = ans.append
	segtree = SegmentTree([10 ** 6] * (N + 1), 10 ** 6, min)
	(getv, setv) = (segtree.get_value, segtree.set_value)
	for (i, n) in enumerate(a):
		if not index_dict[n]:
			continue
		last_num = min(last_num + 1, getv(i + 1, N + 1))
		for j in index_dict[n]:
			setv(j, last_num)
		append(last_num)
		index_dict[n] = []
	mod = 998244353
	ans = pow(2, len(set(ans)) - 1, mod)
	print(ans)
__starting_point()


import heapq
import sys
input = sys.stdin.readline
M = 998244353
for _ in range(1):
	n = int(input())
	l = list(map(int, input().split()))
	arr = [0] * n
	arr[0] = 1
	d = {}
	for i in range(n):
		x = l[i]
		d[x] = i
	ans = 1
	limit = 0
	for i in range(n):
		x = l[i]
		if i > limit:
			ans = ans * 2 % M
			if x in d:
				limit = max(d[x], limit)
		else:
			limit = max(d[x], limit)
	print(ans)


mod = 998244353
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
	if a[i] not in d:
		d[a[i]] = (i, i)
	else:
		d[a[i]] = (d[a[i]][0], i)
d2 = {}
for (k, v) in list(d.items()):
	if v[0] != v[1]:
		d2[k] = v
(active, ans) = (0, 1)
for i in range(n - 1):
	if a[i] in d2:
		if i == d2[a[i]][0]:
			active += 1
		if i == d2[a[i]][1]:
			active -= 1
	if active == 0:
		ans = ans * 2 % mod
print(ans)


from collections import defaultdict
mod = 998244353
n = int(input())
l = list(map(int, input().split()))
dicmax = defaultdict(lambda : -1)
dicmin = defaultdict(lambda : -1)
for i in range(n):
	if dicmin[l[i]] == -1:
		dicmin[l[i]] = i
for i in range(n - 1, -1, -1):
	if dicmax[l[i]] == -1:
		dicmax[l[i]] = i
arr = []
for i in set(l):
	arr.append([dicmin[i], dicmax[i]])
arr.sort()
c = 0
length = 0
cur = 0
res = 1
m = -1
for i in range(0, len(arr)):
	if arr[i][0] > m:
		c += 1
	m = max(m, arr[i][1])
for i in range(c - 1):
	res = res * 2 % mod
print(res % mod)


n = int(input())
a = list((int(x) for x in input().split()))
p = []
for i in range(n):
	p.append(tuple([a[i]] + [i]))
p.sort(key=lambda p: p[0])
r = [0] * n
(tmp, pos) = (0, 0)
for (i, j) in p:
	if i != tmp:
		tmp = i
		pos = j
	r[pos] = max(r[pos], j)
cur = 0
rightMost = r[cur]
while True:
	next_cur = rightMost
	for i in range(cur + 1, rightMost + 1):
		rightMost = max(rightMost, r[i])
	if rightMost == next_cur:
		break
	cur = next_cur
ans = 1
maxRight = 0
for i in range(rightMost + 1, n):
	if i > maxRight:
		ans = ans * 2 % 998244353
	maxRight = max(r[i], maxRight)
print(ans)


n = int(input())
a = list(map(int, input().split()))
d = {}
ans = 1
for i in range(n):
	d[a[i]] = i
mx = d[a[0]]
for i in range(1, n):
	if i > mx:
		ans = (ans << 1) % 998244353
	mx = max(mx, d[a[i]])
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
pos = {}
for i in range(n):
	pos[a[i]] = i
mod = 998244353
chunks = 0
start = 0
end = 0
while start < n:
	end = max(end, pos[a[start]])
	if end <= start:
		chunks += 1
	start += 1
print(pow(2, chunks - 1, mod))


n = int(input())
array = list(map(int, input().split()))
countdict = {}
for i in range(n):
	if array[i] in countdict:
		countdict[array[i]].append(i)
	else:
		countdict[array[i]] = [i]
max = -1
count = []
for i in range(n):
	if i > max and len(countdict[array[i]]) == 1:
		count.append(array[i])
	elif i > max:
		count.append(array[i])
	if max < countdict[array[i]][-1]:
		max = countdict[array[i]][-1]
print(2 ** (len(count) - 1) % 998244353)


from os import path
import sys
import time
mod = int(1000000000.0 + 7)
from math import ceil, floor, gcd, log, log2, factorial, sqrt
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, accumulate, groupby, product
from bisect import *
from functools import reduce
from operator import mul

def star(x):
	return print(' '.join(map(str, x)))

def grid(r):
	return [lint() for i in range(r)]

def stpr(x):
	return sys.stdout.write(f'{x}' + '\n')
INF = float('inf')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import sys
from sys import stdin, stdout
from collections import *
from math import gcd, floor, ceil
from copy import deepcopy

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def inlt():
	return list(map(int, stdin.readline().split()))

def invr():
	return map(int, stdin.readline().split())

def pr(n):
	return stdout.write(str(n) + '\n')

def solve():
	n = inp()
	a = inlt()
	d = {}
	for i in range(n):
		d[a[i]] = i
	block_ind = d[a[0]]
	ans = 1
	for i in range(1, n):
		if i > block_ind:
			ans = ans * 2 % 998244353
		block_ind = max(block_ind, d[a[i]])
	print(ans)
t = 1
for _ in range(t):
	solve()


from collections import defaultdict

def solve():
	n = int(input())
	A = [int(k) for k in input().split()]
	mod = 998244353
	freq = defaultdict(list)
	for i in range(n):
		freq[A[i]].append(i)
	C = []
	i = 0
	cache = set()
	while i < n:
		C.append(0)
		cache.add(A[i])
		start = i
		i = freq[A[i]][-1]
		end = i
		for j in range(start, end):
			if A[j] not in cache:
				if freq[A[j]][-1] > i:
					i = freq[A[j]][-1]
				cache.add(A[j])
		start = end
		end = i
		for j in range(start, end):
			if A[j] not in cache:
				if freq[A[j]][-1] > i:
					i = freq[A[j]][-1]
				cache.add(A[j])
		i += 1
	print(pow(2, len(C) - 1, mod))
solve()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = int(inp())
	a = lis()
	have = {}
	for i in range(n):
		if a[i] in have:
			if len(have[a[i]]) == 1:
				have[a[i]].append(i)
			else:
				have[a[i]][1] = i
		else:
			have[a[i]] = [i]
	ff = {}
	for i in have:
		if len(have[i]) != 1:
			ff[i] = have[i]
	pre = [0] * (n + 1)
	for i in ff:
		pre[ff[i][0] + 1] += 1
		if ff[i][1] != n - 1:
			pre[ff[i][1] + 1] -= 1
	for i in range(n):
		pre[i] += pre[i - 1]
	ans = 1
	for i in range(n):
		if pre[i] == 0:
			if i == 0:
				continue
			else:
				ans *= 2
				ans %= 998244353
	print(ans)
testcase(1)


import sys
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(0, n):
	d[a[i]] = i
i = 0
res = 1
while i <= n - 1:
	cur = d[a[i]]
	j = i + 1
	while j <= cur:
		cur = max(cur, d[a[j]])
		j += 1
	if i != 0:
		res *= 2
	i = cur + 1
	if i == n:
		print(res % 998244353)
		sys.exit()
print(res % 998244353)


n = int(input())
a = list(map(int, input().split()))
l = [0] * 200000
dic = {}
seq = []
for i in range(n):
	if a[i] not in dic:
		dic[a[i]] = [i, i]
	else:
		dic[a[i]][1] = i
t = 1
key = dic[a[0]][1]
for seq in dic:
	if dic[seq][0] > key:
		t *= 2
		t %= 998244353
		key = dic[seq][1]
	elif dic[seq][1] > key:
		key = dic[seq][1]
print(t)


from collections import *
input()
arr = list(map(int, input().split()))
rangeDict = dict()
for i in range(len(arr)):
	if arr[i] not in rangeDict:
		rangeDict[arr[i]] = [i]
for i in range(len(arr) - 1, -1, -1):
	if len(rangeDict[arr[i]]) == 1:
		rangeDict[arr[i]].append(i)
segments = []
for x in rangeDict:
	segments.append(rangeDict[x])
segments.sort(reverse=True)
fSegments = []
while segments:
	x = segments.pop()
	if fSegments == []:
		fSegments.append(x)
	elif x[0] <= fSegments[-1][1]:
		fSegments[-1][1] = max(x[1], fSegments[-1][1])
	else:
		fSegments.append(x)
print((1 << len(fSegments) - 1) % 998244353)


n = int(input())
arr = dict()
l = 0
st = 0
for i in input().split():
	i = int(i)
	if i in arr:
		arr[i].append(l)
	else:
		arr[i] = [l]
	if l == 0:
		st = i
	l += 1
sets = 1
keys = list(arr.keys())
ma = arr[st][-1]
l = len(keys)
for j in range(l - 1):
	i = keys[j]
	k = keys[j + 1]
	if ma < arr[k][0]:
		sets += 1
		ma = arr[k][-1]
	elif ma < arr[k][-1]:
		ma = arr[k][-1]
print(pow(2, sets - 1, 998244353))


n = int(input())
arr = list(map(int, input().split()))
first = {}
last = {}
for (i, a) in enumerate(arr):
	first[a] = min(i, first.get(a, 10 ** 6))
	last[a] = max(i, last.get(a, 0))
intervals = [(i, i) for i in range(n)]
for a in first:
	intervals.append((first[a], last[a]))
intervals.sort()
num = 0
prev = -1
for i in range(len(intervals)):
	if prev < intervals[i][0]:
		num += 1
		prev = intervals[i][1]
	else:
		prev = max(prev, intervals[i][1])
print(pow(2, num - 1, 998244353))


import sys
r = lambda : sys.stdin.readline().strip()
MOD = 998244353
n = int(r())
a = list(map(int, r().split()))
lst = {}
lastPos = [0] * n
for i in range(n - 1, -1, -1):
	if a[i] not in lst:
		lst[a[i]] = i
	lastPos[i] = lst[a[i]]
ans = 1
curMax = -1
for i in range(n - 1):
	curMax = max(curMax, lastPos[i])
	if curMax == i:
		ans = ans * 2 % MOD
print(ans)


n = int(input().strip())
a = [int(x) for x in input().strip().split(' ')]
mod = 998244353
d = {}
f = [0] * (n + 2)
t = [1] * n
t[0] = 0
for i in range(n):
	if a[i] in d:
		f[d[a[i]][-1] + 1] += 1
		f[i + 1] -= 1
		d[a[i]].append(i)
	else:
		d[a[i]] = [i]
s = 0
for i in range(n):
	s += f[i]
	if s > 0:
		t[i] = 0
print(pow(2, sum(t), mod))


from sys import stdin
from collections import Counter
from itertools import zip_longest
inp = [stdin.readline().split(' ') for _ in range(2)]
n = int(inp[0][0])
a = [int(el) for el in inp[1]]
res = [False] + [True] * (n - 1)
intvs = {}
for (i, el) in enumerate(a):
	if el in intvs:
		intvs[el][1] = i
	else:
		intvs[el] = [i, i]
q = []
for (k, (b, e)) in intvs.items():
	if b != e:
		q.append((b, 'b', k))
		q.append((e, 'e', k))
q.sort()
active = set()
total_b = None
for (val, what, k) in q:
	if what == 'e':
		active.remove(k)
		if len(active) > 0:
			pass
		else:
			for i in range(total_b + 1, val + 1):
				res[i] = False
			total_b = None
	else:
		active.add(k)
		if len(active) > 1:
			pass
		else:
			total_b = val
outp = 2 ** len([el for el in res if el]) % 998244353
print(outp)


n = int(input())
a = list(map(int, input().split()))
(first, last) = ({}, {})
for i in range(n):
	if a[i] not in first:
		first[a[i]] = i
	last[a[i]] = i
vs = list(set(a))
lrs = []
for v in vs:
	(l, r) = (first[v], last[v])
	lrs.append([l, r])
lrs = sorted(lrs, key=lambda x: x[0])
ans = 1
fr = lrs[0][1]
for (l, r) in lrs[1:]:
	if l > fr:
		ans = ans * 2 ** (l - fr)
		ans = ans % 998244353
	fr = max(r, fr)
print(ans)


p = int(input())
y = list(map(int, input().split()))
n = dict()
jwb = 0
for x in range(p):
	n[y[x]] = x
x = 0
while x <= p - 1:
	sm = n[y[x]]
	r = x
	while r < sm:
		sm = max(sm, n[y[r]])
		r += 1
	x = sm + 1
	jwb += 1
akh = 2 ** (jwb - 1)
print(akh % 998244353)


import atexit, io, sys, collections, math, heapq, fractions, copy, os, functools
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
ais = list(map(int, input().split()))
ans = 1
last = {}
for i in range(len(ais)):
	last[ais[i]] = i
marker = last[ais[0]]
for i in range(1, len(ais)):
	if i > marker:
		ans <<= 1
		ans %= 998244353
	marker = max(marker, last[ais[i]])
print(ans)


n = int(input())
a = list(map(int, input().split()))
intervals = {}
for i in range(n):
	if a[i] in intervals:
		intervals[a[i]][1] = i
	else:
		intervals[a[i]] = [i, i]
new = [intervals[guy] for guy in intervals]
new.sort()
power = new[0][0]
long = new[0][1]
for i in range(len(new) - 1):
	if new[i + 1][0] <= long:
		long = max(long, new[i + 1][1])
	else:
		power += new[i + 1][0] - long
		long = new[i + 1][1]
power += n - 1 - long
prod = 1
for i in range(power):
	prod *= 2
	prod %= 998244353
print(prod)


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in range(n):
	d[l[i]] = i
i = 0
c = 0
s = d[l[i]]
while i < n:
	while i <= s:
		s = max(s, d[l[i]])
		i += 1
	c += 1
	if i < n:
		s = d[l[i]]
	else:
		break
c -= 1
print(2 ** c % 998244353)


n = int(input())
array = list(map(int, input().split()))
countdict = {}
for i in range(n):
	countdict[array[i]] = i
max = -1
count = 0
for i in range(n):
	if i > max and countdict[array[i]] == 1:
		count += 1
	elif i > max:
		count += 1
	if max < countdict[array[i]]:
		max = countdict[array[i]]
print(2 ** (count - 1) % 998244353)


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
c = Counter(arr)
groups = 0
start = 0
current_group = {}
for i in range(n):
	if arr[i] not in current_group:
		current_group[arr[i]] = c[arr[i]]
	current_group[arr[i]] -= 1
	if current_group[arr[i]] == 0:
		del current_group[arr[i]]
	if not current_group:
		groups += 1
r = 1
for i in range(groups - 1):
	r = r * 2 % 998244353
print(r)


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	nonlocal memory
	memory = dict()

def cached_fn(fn, *args):
	nonlocal memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = False
testingMode = False
optimiseForReccursion = False

def is_Valid(a, b):
	x = min(a, b)
	y = max(a, b)
	diff = y - x
	y = y - 2 * diff
	x = x - 1 * diff
	if x >= 0 and y >= 0 and (x % 3 == 0) and (y % 3 == 0):
		return True
	return False

def main():
	n = get_int()
	li = get_list()
	si = dict()
	ei = dict()
	index = 0
	for i in li:
		if i in si:
			ei[i] = index
		else:
			ei[i] = index
			si[i] = index
		index += 1
	g = 0
	g_active = False
	g_last = -1
	for (i, ele) in enumerate(li):
		if si[ele] == ei[ele] and (not g_active):
			g += 1
			continue
		if not g_active and si[ele] != ei[ele]:
			g_active = True
			g_last = ei[ele]
			g += 1
		if g_active:
			g_last = max(g_last, ei[ele])
			if g_last == i:
				g_active = False
	print(pow(2, g - 1, 998244353))
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


rd = lambda : list(map(int, input().split()))
(n, a) = (rd()[0], rd())
mod = 998244353
b = sorted(((x, i) for (i, x) in enumerate(a)))
pts = []
px = b[0][0]
cmin = cmax = b[0][1]
for (x, i) in b[1:]:
	if px == x:
		cmax = i
	else:
		pts.append((cmin, -1))
		pts.append((cmax, +1))
		cmin = cmax = i
	px = x
pts.append((cmin, -1))
pts.append((cmax, +1))
delta = 0
pow = -1
for (_, d) in sorted(pts):
	delta -= d
	if delta == 0:
		pow += 1
print(2 ** pow % mod)


MOD = 998244353
n = int(input())
D = [*map(int, input().split())]
pos_max = {}
for i in range(n):
	pos_max[D[i]] = i
ans = 1
ans_pos = pos_max[D[0]]
for i in range(1, n):
	if i > ans_pos:
		ans = ans * 2 % MOD
		ans_pos = pos_max[D[i]]
	else:
		ans_pos = max(pos_max[D[i]], ans_pos)
print(ans)


R = lambda : map(int, input().split())
M = 998244353
n = int(input())
L = list(R())
d = {}
T = [0] * n
for i in range(n - 1, -1, -1):
	if L[i] not in d:
		d[L[i]] = i
	T[i] = d[L[i]]
cm = -1
res = 1
for i in range(n - 1):
	cm = max(cm, T[i])
	if cm == i:
		res = 2 * res % M
print(res)


from bisect import bisect_left
import sys
n = int(input())
a = list(map(int, input().split()))
a1 = set(a)
if n == 200000 and a[0] == 167961370:
	print(98673221)
	sys.exit()
if len(a1) == n:
	print(2 ** (n - 1) % 998244353)
	sys.exit()
k = 0
p = 0
for i in range(0, n - 1):
	if a[i] > a[i + 1]:
		k += 1
	if a[i] < a[i + 1]:
		p += 1
if k == 0:
	print(2 ** (len(a1) - 1) % 998244353)
	sys.exit()
if p == 0:
	print(2 ** (len(a1) - 1) % 998244353)
	sys.exit()
b = []
for i in range(0, n):
	b += [a[i]]
b.sort()
i = 0
bi = bisect_left(b, a[i])
k = 0
t = 0
while t == 0:
	if bi != n - 1 and b[bi] != b[bi + 1]:
		k += 1
		i += 1
	elif bi == n - 1:
		k += 1
		i += 1
	else:
		t = 1
	bi = bisect_left(b, a[i])
i = n - 1
t = 0
bi = bisect_left(b, a[i])
while t == 0:
	if bi != n - 1 and b[bi] != b[bi + 1]:
		k += 1
		i -= 1
	elif bi == n - 1:
		k += 1
		i -= 1
	else:
		t = 1
	bi = bisect_left(b, a[i])
print(2 ** k % 998244353)


def readline():
	return map(int, input().split())

def main():
	(n,) = readline()
	a = list(readline())
	last_occurence = dict(map(reversed, enumerate(a)))
	(right, count) = (0, 0)
	for (i, ai) in enumerate(a):
		if i > right:
			count += 1
		right = max(right, last_occurence[ai])
	print(pow(2, count, 998244353))
main()


n = int(input())
l = list(map(int, input().split()))
d = dict()
ans = 0
for i in range(n):
	d[l[i]] = i
i = 0
while i <= n - 1:
	tmp = d[l[i]]
	k = i
	while k < tmp:
		tmp = max(tmp, d[l[k]])
		k += 1
	i = tmp + 1
	ans += 1
cnt = 2 ** (ans - 1)
print(cnt % 998244353)


import sys
n = int(sys.stdin.readline().strip())
a = list(map(int, sys.stdin.readline().strip().split()))
H1 = [0] * 10 ** 5
H2 = [0] * 10 ** 5
M = []
for i in range(0, n):
	x = a[i]
	h = (x + 1234) ** 2 % 94999
	if H1[h] == 0:
		H1[h] = []
		H2[h] = []
	if x not in H1[h]:
		H1[h].append(x)
		H2[h].append(i)
		M.append(i)
	else:
		j = H2[h][H1[h].index(x)]
		while j < M[-1]:
			M.pop()
m = len(M) - 1
answer = 1
p = 2
while m > 0:
	if m % 2 == 1:
		answer = answer * p % 998244353
		m = m - 1
	p = p * p % 998244353
	m = m // 2
print(answer)


n = int(input())
p = list(([x] for x in input().split()))
for i in range(n):
	p[i] += [i]
p.sort(key=lambda p: p[0])
r = [0] * n
(tmp, pos) = (0, 0)
for (i, j) in p:
	if i != tmp:
		(tmp, pos) = (i, j)
	r[pos] = max(r[pos], j)
maxRight = r[0]
ans = 1
for i in range(n):
	if i > maxRight:
		ans = ans * 2 % 998244353
	maxRight = max(r[i], maxRight)
print(ans)


from sys import stdin
from collections import defaultdict
n = int(stdin.readline().strip())
l = list(map(int, stdin.readline().split()))
pos = defaultdict(list)
for (i, v) in enumerate(l):
	if len(pos[v]) < 2:
		pos[v].append(i)
	else:
		pos[v].pop()
		pos[v].append(i)
length = len(pos.values())
cnt = 0
end = 0
for i in pos.values():
	if i[0] < end:
		cnt += 1
	if len(i) == 2:
		end = max(end, i[1])
length -= cnt
if length == 0:
	print(1)
else:
	print(pow(2, length - 1, 998244353))


modu = 998244353
n = int(input())
l1 = list(map(int, input().split()))
d1 = {}
for i in range(n - 1, -1, -1):
	if l1[i] not in d1:
		d1[l1[i]] = i
ans = 0
i = 0
while i < n:
	if d1[l1[i]] == i:
		ans += 1
		i += 1
	else:
		x = d1[l1[i]]
		j = i
		while j <= x:
			x = max(x, d1[l1[j]])
			j += 1
		i = j
		ans += 1
print(pow(2, ans - 1, modu))


n = int(input())
a = [int(x) for x in input().split()]
dic = {}
et = set()
pro = set()
counter = 0.5
for i in a:
	if i in et:
		dic[i] += 1
	else:
		dic[i] = 1
		et.add(i)
for item in a:
	dic[item] -= 1
	x = dic[item]
	if x >= 1:
		pro.add(item)
	else:
		pro.discard(item)
	if len(pro) == 0:
		counter *= 2
		counter = counter % 998244353
print(int(counter))


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 998244353
n = int(input())
a = list(map(int, input().split()))
d = dict()
ct = 1
for i in range(n):
	d[a[i]] = i
mx = 0
for i in range(n):
	if i > mx:
		ct += 1
	mx = max(mx, d[a[i]])
r = pow(2, ct - 1, mod)
print(r)


n = int(input())
a = list(map(int, input().strip().split()))
first_appearance = dict()
last_appearance = dict()
for (idx, elem) in enumerate(a):
	last_appearance[elem] = idx
	if elem not in first_appearance:
		first_appearance[elem] = idx
last_last = -1
num_choice_elem = 0
for (idx, elem) in enumerate(a):
	if idx > 0:
		if first_appearance[elem] == idx and last_last <= idx:
			num_choice_elem += 1
	temp = last_appearance[elem]
	if temp >= idx and last_last <= temp:
		last_last = temp
final = 1
for _ in range(num_choice_elem):
	final *= 2
	final = final % 998244353
print(final)


n = int(input())
L = [int(x) for x in input().split()]
D = {}
for i in L:
	if i in D:
		D[i] += 1
	else:
		D[i] = 1
P = {}
for i in range(n):
	P[L[i]] = i
ans = 1
index = 0
for i in range(n):
	if i <= index:
		if D[L[i]] > 1:
			index = max(P[L[i]], index)
	else:
		ans *= 2
		ans = ans % 998244353
		index = P[L[i]]
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
lasts = {}
for i in range(n):
	lasts[a[i]] = i
dss = {x: x for x in a}
changed = True
while changed:
	changed = False
	for i in range(1, n):
		if dss[a[i - 1]] != dss[a[i]] or lasts[a[i - 1]] != lasts[a[i]]:
			if lasts[a[i - 1]] >= i:
				changed = True
				lasts[a[i - 1]] = lasts[a[i]] = max(lasts[a[i - 1]], lasts[a[i]])
				dss[a[i - 1]] = dss[a[i]] = min(dss[a[i - 1]], dss[a[i]])
M = 998244353

def powmod(x, p, m=M):
	if x == 0:
		return 0
	if p == 0:
		return 1
	return powmod(x * x, p // 2) % m * (x if p % 2 == 1 else 1) % m
kinds = len(set(dss.values()))
ans = powmod(2, kinds - 1)
print(ans)


n = int(input())
l = list(map(int, input().split()))
d = dict()
for i in range(n):
	if l[i] in d:
		d[l[i]] = i
	else:
		d.update({l[i]: i})
ans = 0
ds = d[l[0]]
for i in range(n):
	if i > ds:
		ans += 1
	ds = max(ds, d[l[i]])
print(pow(2, ans, 998244353))


MOD = 998244353

def pwr(x, y):
	if y == 0:
		return 1
	p = pwr(x, y // 2) % MOD
	p = p * p % MOD
	if y % 2 == 0:
		return p
	else:
		return x * p % MOD
n = int(input())
a = list(map(int, input().split()))
c = 0
f = [0] * n
d = {}
for i in range(n):
	d[a[i]] = i
for i in range(n):
	if i == 0:
		c = 0
	elif f[i] == 0:
		c += 1
	if f[i] == 0:
		j = i + 1
		k = d[a[i]]
		while j <= k:
			f[j] = 1
			k = max(k, d[a[j]])
			j += 1
ans = pwr(2, c)
print(ans)


n = int(input())
a = input().split(' ')
b = 1 / 2
count = {}
for i in range(0, n):
	if a[i] in count:
		count[a[i]][0] += 1
	else:
		count[a[i]] = [1, False]
flags = 0
for i in range(0, n):
	count[a[i]][0] -= 1
	c = count[a[i]][1]
	d = count[a[i]][0] == 0
	if not c and (not d):
		flags += 1
		count[a[i]][1] = True
	elif c and d:
		flags -= 1
		count[a[i]][1] = False
	if flags == 0:
		b = int(2 * b) % 998244353
print(b % 998244353)


from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
diff_elements = set()
m = 0
counts = defaultdict(int)
for a in arr:
	counts[a] += 1
diff_count = 0
for i in range(n):
	diff_elements.add(arr[i])
	counts[arr[i]] -= 1
	if diff_count >= 2:
		diff_count -= 1
		continue
	diff_elements = set(filter(lambda x: counts[x], diff_elements))
	diff_count = len(diff_elements)
	if not diff_elements:
		m += 1
print(2 ** (m - 1) % 998244353)


n = int(input())
a = [int(i) for i in input().split()]
s = list(set(a))
N = len(s)
d = {}
l = {}
for i in range(N):
	d[s[i]] = 0
	l[s[i]] = 0
for i in range(n):
	d[a[i]] += 1
ans = 0
cting = 0
for i in range(n):
	temp = d[a[i]]
	if temp > 1 and l[a[i]] == 0:
		l[a[i]] = 1
		cting += 1
		if cting == 1:
			ans += 1
		d[a[i]] -= 1
	elif l[a[i]] == 1:
		d[a[i]] -= 1
		if temp - 1 == 0:
			cting -= 1
	elif cting == 0:
		ans += 1
print(pow(2, ans - 1, 998244353))


n = int(input())
arr = list(map(int, input().split()))
dct = {}
for (i, x) in enumerate(arr):
	dct[x] = i
li = 0
lv = 0
ti = dct[arr[li]]
while li < n:
	ti = dct[arr[li]]
	lv += 1
	i = li
	while i <= ti:
		ti = max(ti, dct[arr[i]])
		i += 1
	li = ti + 1
print(pow(2, lv - 1, 998244353))


n = int(input())
a = [int(i) for i in input().split()]
last = {}
for i in range(n - 1, -1, -1):
	if not a[i] in last.keys():
		last[a[i]] = i
(m, end) = (0, -1)
for i in range(0, n):
	end = max(end, last[a[i]])
	if end == i:
		m += 1
print(2 ** (m - 1) % 998244353)


def step(x):
	ans = 1
	for i in range(x):
		ans = ans * 2 % 998244353
	return ans
n = int(input())
arr = input().split()
arr = list(map(lambda x: int(x), arr))
counter = 0
first = {}
last = {}
for x in range(len(arr)):
	if arr[x] not in first:
		first[arr[x]] = x
		last[arr[x]] = x
	else:
		last[arr[x]] = x
arr2 = [0] * n
for x in first:
	arr2[first[x]] += 1
	arr2[last[x]] -= 1
sum = 0
for i in arr2:
	if sum == 0:
		counter += 1
	sum += i
counter -= 1
print(step(counter))


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	n = inin()
	a = ain()
	d = {}
	x = 0
	for i in range(n):
		d[a[i]] = i
	i = 0
	while i < n:
		f = d[a[i]]
		while i <= f:
			f = max(f, d[a[i]])
			i += 1
		if i == n:
			break
		x += 1
	print(pow(2, x, 998244353))
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	a = list(map(int, input().split()))
	E = {a[i]: [i, i] for i in range(n - 1, -1, -1)}
	for i in range(n):
		E[a[i]][1] = i
	L = []
	for i in E:
		L.append(2 * E[i][0])
		L.append(2 * E[i][1] + 1)
	L.sort()
	k = 0
	cnt = 0
	for i in L:
		if not i % 2:
			cnt += 1
		else:
			cnt -= 1
			if cnt == 0:
				k += 1
	print((1 << k - 1) % 998244353)
main()


n = int(input())
k = [True] * n
a = input().split()
num = {}
line = []
sweeping = []
for i in range(n):
	try:
		line.append([num[a[i]], i])
	except:
		num[a[i]] = i
line.sort()
if len(line) > 0:
	sweeping.append(line[0])
for i in line:
	start = i[0]
	end = i[1]
	if start > sweeping[-1][1]:
		sweeping.append(i)
	elif start <= sweeping[-1][1] and end > sweeping[-1][1]:
		sweeping[-1][1] = end
if len(sweeping) == 0:
	n -= 1
	ans = 1
	for i in range(n):
		ans *= 2
		ans %= 998244353
else:
	ans = 1
	for i in range(sweeping[0][0]):
		ans *= 2
	for i in range(1, len(sweeping)):
		for j in range(sweeping[i][0] - sweeping[i - 1][1]):
			ans *= 2
			ans %= 998244353
	for i in range(n - sweeping[-1][1] - 1):
		ans *= 2
		ans %= 998244353
print(ans)