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