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