n=int(input())
l=list(input().strip().split())
sum=0
dic={}
for i in range(n):
    if len(l[i]) in dic:
        dic[len(l[i])]+=1
    else:
        dic[len(l[i])]=1
for i in range(n):
    for k in dic:
        count=dic[k]
        if k>=len(l[i]):
            a=2*len(l[i])
            for j in range(len(l[i])):
                sum+=int(l[i][j])*(10**(a-1))*count
                sum=sum%998244353
                a-=1
                sum+=int(l[i][j])*(10**(a-1))*count
                sum=sum%998244353
                a-=1
        else:
            a=2*k
            for j in range(len(l[i])):
                if len(l[i])-j>k:
                    sum+=int(l[i][j])*(10**(len(l[i])+k-1))*count*2
                    sum=sum%998244353
                else:
                    sum+=int(l[i][j])*(10**(a-1))*count
                    sum=sum%998244353
                    a-=1
                    sum+=int(l[i][j])*(10**(a-1))*count
                    sum=sum%998244353
                    a-=1
print(sum)
