n=int(input()) a=list(map(int,input().split())) a.sort() mod=998244353 ans=0 for i in a: ans=10*ans+i ans%=mod print(ans)