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