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