MOD = 998244353 n = int(input()) A = list(input().split()) A.sort() pow10 = [1] * 20 for i in range(1, 20): pow10[i] = (10 * pow10[i - 1]) % MOD ans = 0 for a in A: ans = (ans * pow10[len(a)] + int(a)) % MOD print(ans)