n = int(input())
num = input().rstrip().split(" ")
ans = 0
length = [0 for _ in range(10)]
for k in num:
    length[len(k)] += 1
for i in num:
    check = len(i)
    for j in range(10):
        if check < j:
            for l in range(check):
                ans += 11*length[j]*int(i[check-l-1])*10**(2*l)
        elif check == j:
            for x in range(check):
                ans += 11*length[j]*int(i[check-x-1])*10**(2*x)
        else:
            count = 0
            for u in range(check-j):
                ans += 11*length[j]*int(i[check-u-1])*10**count
                count += 2
            for v in range(check-j,check):
                ans += 2*length[j]*int(i[check-v-1])*10**count
                count += 1
    ans %= 998244353
print(ans)