from functools import cmp_to_key def comp(a, b): if a + b < b + a: return -1 elif a + b == b + a: return 0 else: return 1 N = int(input()) A = list(map(str, input().split())) A.sort(key=cmp_to_key(comp)) mod = 998244353 pow_10 = [pow(10, i, mod) for i in range(19)] now = 0 for i in range(N): len_a = len(A[i]) now = (now * pow_10[len_a]) % mod now = (now + int(A[i])) % mod print(now)