n=int(input())
array=list(map(int,input().split(' ')))
count=[0 for i in range(10)]
for i in array:
        count[len(str(i))-1]+=1

result=0
for i in array:
        for l,c in enumerate(count):
                result+=i*10*c
                d=10*(100)**l
                i=i%d+(i-i%d)*10
                result+=i*c

                
print(result%998244353)