def f(n): s = str(n) while len(s) < 6: s += s[0] return s MOD = 998244353 N = int(input()) *A, = map(int, input().split()) A.sort(f) x = 0 for a in A: for _ in range(len(str(a))): x *= 10 x %= MOD x += a x %= MOD print(x)