import sys, math
readline = sys.stdin.readline

n = int(readline())
a = list(map(int,readline().split()))
tmp = [[0 for _ in range(20)] for _ in range(10)]

for i in range(n):
    s = [0 for j in range(10)]
    ss = str(a[i])
    for j in range(10):
        if j < len(ss):
            s[9 - j] = ord(ss[len(ss) - j - 1])
        else:
            s[9 - j] = 58 + j - len(ss)
    for j in range(10):
        tmp[j][s[9 - j] - 48] += 1
asd = 0
asd2 = 0
for i in range(10):
    tp = 0
    tp1 = 0
    for j in range(10):
        for k in range(10,20):
            if tmp[i][k] != 0 and tmp[i][j] != 0:
                asd2 = (asd2 + j * tmp[i][j] * 2 * tmp[i][k] * pow(10,i * 2 - (k - 10))) % 998244353
        for k in range(10):
            tp += (10 * j + k) * tmp[i][k] * tmp[i][j]
    asd = (asd + tp * pow(100,i)) % 998244353

print(asd + asd2)