from sys import stdin

mod = 998244353
add = lambda a, b: (a + b) % mod
mult = lambda a, b: (a * b) % mod
n, a, ans = int(input()), [str(x) for x in stdin.readline().split()], 0
mem = [0] * 11
mem[0] = n

for i in range(n):
    for k, j in enumerate(a[i]):
        mem[k + 1] += 1

for i in range(n):
    for k, j in enumerate(a[i][::-1]):
        ans = add(ans, mult(mult(int(j), pow(10, k * 2)), mem[k]))
        ans = add(ans, mult(mult(int(a[i][::-1][k:]), n - mem[k]), pow(10, k * 2 - 1)))

    for k, j in enumerate(a[i][::-1]):
        ans = add(ans, mult(mult(int(j), pow(10, k * 2 + 1)), mem[k + 1]))
        ans = add(ans, mult(mult(int(a[i][::-1][k:]), n - mem[k + 1]), pow(10, k * 2)))

print(int(ans))
