N=int(input()) A=list(map(int,input().split())) B=[] for i,a in enumerate(A): B.append((a,i)) B.sort() C=[] for a,i in B: C.append(i) x=0 for c in C: x=(10*x+A[c])%998244353 print(x)