N = int(input()) A = list(map(int, input().split())) MOD = 998_244_353 x = 0 for a in sorted(A): x *= 10 x += a x %= MOD print(x)