n=int(input())
arr=list(map(int,input().split()))

lengths = [0 for i in range(11)]
for i in arr:
    lengths[len(str(i))-1]+=1


ans=0

for i in arr:
    for j in range(len(lengths)):
            ans+=i*10*lengths[j] # if number is at position of a
            #print(ans)
            
            d=10*(100)**j
            i=i%d+(i-i%d)*10
            ans+=i*lengths[j]  # if number is at position of b
    #print(ans)
                
print(ans%998244353)