N=int(input()) A=list(map(str,input().split())) A=[list(a) for a in A] A=[a+[a[-1]]*18 for a in A] A.sort() ans=[] for a in A: a=a[:-18] 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)