"""

based on
https://yamate11.github.io/blog/posts/2021/11-03-abc225-f-string-cards/

"""

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

A = list(input().split())

from functools import cmp_to_key

from functools import cmp_to_key

def cmp(a, b):
    X = a+b
    Y = b+a
    if X < Y:
        return -1
    elif X==Y:
        return 0
    else:
        return 1

B = list(sorted(A, key=cmp_to_key(cmp)))

ans = "".join(B)
mod = 998244353

x = 0
for c in ans:
    x *= 10
    x += int(c)
    x %= mod

print (x)