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