n=int(input())
M=998244353
a=list(map(int,input().split()))
a.sort()
x=0
for v in a:
  x=10*x+v
  x%=M
print(x)