mod = 998244353
N = int(input())
A = list(map(int, input().split()))
x = 0
for i in sorted(A):
	x = 10 * x + i
	x %= mod
print(x)