import sys
from math import sqrt
input = lambda: sys.stdin.readline().rstrip("\r\n")
mod=998244353
n=int(input())
a=input().split()
ans=0
d=dict()
for i in a:
    d[len(i)]=d.get(len(i),0)+1
#print(d)
for i in a:
    j=1
    tot=0
    while j<len(i):
        if j in d:
            b=str()
            b+=i[:len(i)-j]+'00'*j
            ans += int(b) * d[j]*2
            #print(b,ans)
            b=str()
            for k in i[len(i)-j:]:
                b+=k*2
            #print(b)
            ans += int(b) * d[j]
            tot+=d[j]
        j+=1
    b=str()
    for j in i:
        b+=j*2
    ans+=int(b)*(n-tot)
    ans=ans%mod
print(ans % mod)



