import sys input = sys.stdin.readline MOD = 998244353 N = int(input()) A = list(map(int, input().split())) A.sort() x = 0 for a in A: x = (10*x%MOD + a)%MOD print(x)