import typing import sys from collections import defaultdict, deque import heapq from functools import cmp_to_key input = lambda: sys.stdin.readline().strip() inf = 10**18 mod = 998244353 # import pypyjit # pypyjit.set_param('max_unroll_recursion=-1') # sys.setrecursionlimit(10**6) def solve(): def cmp(x, y): if len(x) > len(y): return 1 if len(x) < len(y): return -1 if int(x) < int(y): return -1 if int(x) > int(y): return 1 return 0 N = int(input()) l = input().split() l.sort() ans = 0 for x in l: ans = pow(10, len(x))*ans + int(x) ans %= mod print(ans) def main(): t = 1 for _ in range(t): solve() main()