MOD = 998244353 class T: def __init__(self, x): self.x = x def __lt__(self, other): return self.x + other.x < other.x + self.x n = int(input()) A = [T(x) for x in 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: a = a.x ans = (ans * pow10[len(a)] + int(a)) % MOD print(ans)