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: introductory

Starter code:

Solutions:
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)


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()
#print(*arrx)
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
    #print(rem,count)
    if(flag==1):
        countx=count+rem
    else:
        countx=count+rem-1
    print(pow(2,countx,mod))


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()

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
#print(d)
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())
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(n, a, dss, lasts, kinds)
#print([powmod(2, i, 13) for i in range(10)])

print(ans)


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)

mod = 998244353
n = int(input())

a = list(map(int,input().split()))

d = {}

for i in range(n):
	if a[i] in d:
		d[a[i]].append(i)
	else:
		d[a[i]] = [i,]

i = 1
ans = 1
curr = 0
d2 = {}
ma = d[a[0]][-1]
d2[a[0]] = 1

while i<n:
	l = 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,l[-1])

print(ans)

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))

    
    


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

def __starting_point():
    main()
__starting_point()

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().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


# print(first_appearance)
# print(last_appearance)

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
            # print(idx, elem)

    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)

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)

# import math
# import sys
n = int(input().strip())
a = [int(x) for x in input().strip().split(" ")]
mod = 998244353
d = {}
# c = {}
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))

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)

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 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))

''' Thruth can only be found at one place - THE CODE '''

''' Copyright 2018, SATYAM KUMAR'''
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) # max depth of recursion
threading.stack_size(2**27)  # new thread will get stack of such size

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, 1e9)
max_operation = Operation("max", max, max_multiple, -1e9)
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): #n**0.5 complex 
    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):
    """Returns True if n is prime."""
    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


# -------------------------------------------------------------- MAIN PROGRAM
TestCases = False
testingMode = False
optimiseForReccursion = False #Can not be used clubbed with TestCases
def is_Valid(a,b):
    #print(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))
    




# --------------------------------------------------------------------- END


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()

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())
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)

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)

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()
        


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
    '''
for i in arr:
    arr[i].sort()
    '''



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]
        #print(ma,k)
        
    elif(ma<arr[k][-1]):
        ma = arr[k][-1]
#print(sets)
print(pow(2,sets-1,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)