# Enter your code here. Read input from STDIN. Print output to STDOUT

MOD=998244353
def make(n):
    s=str(n)[::-1]
    A=[]
    for x in s:
        A+=[int(x),0]
    temp=0
    power=1
    for i in range(len(A)):
        temp+=A[i]*power
        temp%=998244353
        power*=10
        power%=998244353
    return temp%998244353
n=input()
A=list(map(int,raw_input().strip().split(' ')))
from collections import defaultdict

dic=defaultdict(int)
for x in A:
    #print(x,x,x)
    dic[len(str(x))]+=1

lengths=[0]*(11)
for x in dic:
    lengths[x]=dic[x]
    
AA=[make(x) for x in A]
temp=0
for x in AA:
    temp+=x
    temp%=998244353

total=(11*temp*len(A))%998244353

#print(total)
##need to subtract them back
deduct=0

def find_deduct(x):
    n=len(str(x))
    s=str(x)
    temp1=0
    temp2=0
    ans=0
    
    for k in xrange(n-1,0,-1):
        temp1*=100
        temp1+=int(s[n-1-k])
        temp1%=998244353
        temp2*=10
        temp2+=int(s[n-1-k])
        temp2%=998244353
        temp3=(lengths[k]*(-11*temp1+2*temp2))%998244353
        temp3=(temp3*pow(10,2*k,998244353))%998244353
        ans+=temp3
        ans%=998244353
    return ans

#BB=[find_deduct(x) for x in A]
deduct=0
for x in A:
    deduct+=find_deduct(x)
    deduct%=998244353
#print([(-find_deduct(x))%998244353 for x in A])
#print(deduct)
print((total+deduct)%998244353)
    
        


