N=int(input()) A=list(map(str,input().split())) A=[a for a in A] A=[(a*(-(-19//len(a))),len(a)) for a in A] A.sort() ans=[] for a,c in A: a=a[:c] ans+=a fa=0 left=1 p=998244353 for i in range(len(ans)-1,-1,-1): fa+=left*int(ans[i]) left*=10 left%=p fa%=p print(fa%p)