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