from functools import reduce n = int(input()) arr = list(map(int, input().split())) arr.sort() print(reduce(lambda a, b:((10*a) + b) % 998244353, arr) % 998244353)