import sys, math
readline = sys.stdin.readline

n = int(readline())
a = list(map(int,readline().split()))
tmp = [[0 for _ in range(11)] for _ in range(10)]
for i in range(n):
    s = str(a[i])
    s = chr(58) * (10 - len(s)) + s
    for j in range(10):
        tmp[j][ord(s[9 - j]) - 48] += 1
asd = 0
for i in range(10):
    tp = 0
    for j in range(10):
        if tmp[i][10] != 0:
            tp += j * tmp[i][j] * 2
        for k in range(10):
            tp += (10 * j + k) * tmp[i][k] * tmp[i][j]
    asd = (asd + tp * pow(100,i)) % 998244353

print(asd)