M = 998244353 n = int(input()) A = [int(_) for _ in input().split()] A.sort() S = 0 for i in range(n): S = (10 * S + A[i]) % M print(S)