# import math
# n, k = map(int, raw_input().split())
# p = (-3 + int(math.sqrt(9+8*(n+k))))/2;
# # print(n-p)
n = int(raw_input())
a = raw_input().split()
# k = len(a[0])
# arr = [0]*(2*k)
# ans = 0
# for x in a:
#     st1 = ""
#     for e in x:
#         st1 = st1+e+e
#     ans = (ans + int(st1)*n)%998244353
# # print(ans)
arr = [0]*11
for x in a:
    arr[len(x)] += 1

ans = 0
arrcum = [0]*11
arrcum[10] = arr[10]
for i in range(9, 0, -1):
    arrcum[i] = arrcum[i+1] + arr[i]

for x in a:
    st1 = ""
    for e in x:
        st1 = st1+e+e
    # print(">", st1, arrcum[len(x)])
    ans = ans + int(st1)*(arrcum[len(x)])
    for l in range(1, len(x)):
        if arr[l] == 0:
            continue
        st1 = ""
        for i in range(l, len(x)):
            st1 = st1 + x[i] +x[i]
        # print(l, st1)
        # print("@", x[:-l]+('0'*l*2), arr[l]*2)
        ans = ans + int(st1)*(l) + int(x[:-l]+('0'*l*2))*arr[l]*2
print(ans%998244353)
