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