import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
mod=998244353
cnt=[0]*20
for i in range(n):
    cnt[len(str(a[i]))-1]+=1
ans=0
for x in a:
    for n,k in enumerate(cnt):
        ans+=x*10*k
        d=10*100**n
        x=(x%d)+(x-x%d)*10
        ans+=x*k
print(ans%mod)