mod=998244353 n=int(input()) L=list(map(int,input().split())) L.sort() x=0 for e in L: x*=10 x+=e x%=mod print(x%mod)