from collections import deque def cmp_to_key(a, b): return a + b <= b + a def merge(S, T): Q = deque() for s in S: Q.append(s) for t in T[::-1]: Q.append(t) L = [] while len(Q) >= 2: if cmp_to_key(Q[0], Q[-1]): L.append(Q.popleft()) else: L.append(Q.pop()) L.append(Q.pop()) return L def mergeSort(A): mid = len(A)//2 if len(A) <= 1: return A L, R = A[:mid], A[mid:] L = mergeSort(L) R = mergeSort(R) A = merge(L, R) return A N = int(input()) A = list(input().split()) A = mergeSort(A) ans = 0 mod = 998244353 M = 20 ten = [1] * M for i in range(1, M): ten[i] = (ten[i - 1] * 10) % mod for a in A: ans = (ans * ten[len(a)] + int(a)) % mod print(ans)