n=int(input())
a=list(map(str,input().split()))
sizes=[0]*10
MOD=998244353
for i in range(n):
  sizes[len(a[i])-1]+=1
dp=[0]*10
for i in range(10):
  for j in range(10):
    if i<=j:
      dp[i]=(dp[i]+(11*sizes[j]*10**i)%MOD*10**i)%MOD
    else:
      dp[i]=(dp[i]+(20*sizes[j]*10**i)%MOD*10**j)%MOD

ans=0
for i in range(n):
  for j in range(len(a[i])):
    l=len(a[i])-j-1
    ans=(ans+dp[l]*int(a[i][j]))%MOD
print(ans)