def ch(a):
    cnt = 0
    while a > 0:
        a //= 10
        cnt += 1
    return cnt
a = int(input())
b = list(map(int,input().split()))
k = [0] * 10
for i in range(a):
    k[ch(b[i])] += 1
summ = 0
summ1 = 0
for i in range(a):
    ot = [b[i] * 10, b[i] // 10 * 100 + b[i] % 10]
    for j in range(2, 25):
        n = ot[0] // 10
        n = str(n)[::-1]
        d = ''
        j1 = j
        j //= 2
        for x in range(min(j, len(n))):
            d += n[x] + '0'
        d += n[j:]
        d = d[::-1]
        if j1 % 2 == 0:
            d += '0'
        ot.append(int(d))
    l = ch(b[i])
    for j in range(10):
        if l == j:
            summ1 += (k[j]) * (ot[j * 2 - 2] + ot[j * 2 - 1])
        else:
            summ += k[j] * (ot[j * 2 - 2] + ot[j * 2 - 1])
    #print(summ, summ1)
print((summ + summ1) % 998244353)
