n,*a=map(int,open(0).read().split())
M=998244353
a.sort()
x=0
for i in a:
  x=x*10+i
  x%=M
print(x)