from collections import Counter

 

M = 998244353

n = int(eval(input()))

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

x, c, r = next(a), Counter(a), 0

if x == c[0] == 0:

    r = p = i = 1

    while c[i]:

        r = r * pow(p, c[i], M) % M

        p = c[i]; n -= p; i += 1

print(((r, 0)[n > 1]))

from collections import Counter

 

M = 998244353

n = int(eval(input()))

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

x, c = next(a), Counter(a)

r = 0

if x == c[0] == 0:

    r = p = i = 1

    try:

        while True:

            x = c.get(i)

            r = r * pow(p, x, M) % M

            p = x; n -= p; i += 1

    except:

        pass

print(((r, 0)[n > 1]))

from collections import Counter

M = 998244353
n = int(eval(input()))
a = list(map(int, input().split()))
x, c, r = next(a), Counter(a), 0
if x == c[0] == 0:
    r = p = i = 1
    while c[i]:
        r = r * pow(p, c[i], M) % M
        p = c[i]
        n -= p
        i += 1
print(((r, 0)[n > 1]))

from collections import Counter

M = 998244353
n = int(eval(input()))
a = list(map(int, input().split()))
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
    r = p = i = 1
    try:
        while True:
            x = c.get(i)
            r = r * pow(p, x, M) % M
            p = x
            n -= p
            i += 1
    except:
        pass
print(((r, 0)[n > 1]))

-x, c, r = next(a), Counter(a), 0 +x, c = next(a), Counter(a) +r = 0 -    while c[i]: -        r = r * pow(p, c[i], M) % M -        p = c[i] -        n -= p -        i += 1 +    try: +        while True: +            x = c.get(i) +            r = r * pow(p, x, M) % M +            p = x +            n -= p +            i += 1 +    except: +        pass