MOD = 998244353 N = int(input()) *A, = map(int, input().split()) A.sort(str) x = 0 for a in A: for _ in range(len(str(a))): x *= 10 x %= MOD x += a x %= MOD print(x)