n = int(input())
A = list(map(int, input().split()))

mod = 998244353
A.sort()
x = 0
for i in range(n):
    x = x * 10 + A[i]
    x %= mod

print(x)