def first(num,l):
    ans = 0
    p   = 10
    i   = 0
    while num:
        i += 1
        n   = num%10
        num /= 10
        ans += n*p
        if i<l:
            p *= 100
        else:
            p *= 10
    return ans


def second(num,l):
    ans = 0
    p   = 1
    i   = 0
    while num:
        i += 1
        n   = num%10
        num /= 10
        ans += n*p
        if i<=l:
            p *= 100
        else:
            p *= 10
    return ans

N   = input()
arr = raw_input().split(" ")
length = [len(x) for x in arr]
count   = [0]*11

for i in length:
    count[i] += 1
arr = map(int,arr)
mod = 998244353
s   = 0

for i in arr:
    for j in range(1,11):
        s= (s+first(i,j)*count[j])%mod
        s= (s+second(i,j)*count[j])%mod
print s
