#
#   Bad codeforces template TM
#
#       Zeyu, 2019
#

from sys import stdin, stdout, setrecursionlimit

input = stdin.readline
flush = stdout.flush

# setrecursionlimit(1000000)

############################################################

OUT = []


def write(item, sep=" "):
    if type(item) is int:
        OUT.append(str(item))
    elif type(item) is list:
        if type(item[0]) is int:
            OUT.append(sep.join(map(str, item)))
        else:
            OUT.append(sep.join(item))
    else:
        OUT.append(item)


def PRINT():
    print("\n".join(OUT))


GI = lambda: int(input())
GS = lambda: input()[:-1]

gi = lambda: list(map(int, input().split()))
gs = lambda: input().split()

############################################################

n = GI()
arr = gs()

dig = [0] * 11
for i in arr:
    dig[len(i)] += 1

tot = 0
for i in arr:
    for length in xrange(1, 11):
        qnt = dig[length]
        if qnt == 0:
            continue
        num1 = ["0"] * 21
        num2 = ["0"] * 21
        p1 = 20
        p2 = 19
        for d in reversed(i):
            num1[p1] = num2[p2] = d
            p1 -= 1
            p2 -= 1
            if length:
                length -= 1
                p1 -= 1
                if length:
                    p2 -= 1
        tot = (tot + qnt * (int("".join(num1).lstrip("0")) + int("".join(num2).lstrip("0")))) % 998244353

print tot