N = gets.to_i
A = gets.split.map(&:to_i).sort
MOD = 998244353
x = 0
A.each do |a|
	x = (x * 10 + a) % MOD
end
puts x