mod = 998244353
n = input()
a = map(int, raw_input().split())

POWER = [1 for i in range(30)]
for i in range(1, 25):
    POWER[i] = POWER[i - 1] * 10
    POWER[i] %= mod

LENS = {}
for i in a:
    try:
        LENS[len(str(i))] += 1
    except KeyError:
        LENS[len(str(i))] = 1

def get(x):
    digits = []
    p = 1
    while x:
        digits.append(x % 10)
        p *= 10
        x /= 10
    p *= p
    p /= 10
    digits = digits[::-1]
    res = 0
    cur_len = len(digits)
    zz = cur_len - 1
    for i in digits:
        c = 0
        for j in LENS:
            if j >= cur_len:
                c += LENS[j] * (POWER[2 * zz] + POWER[(2 * zz) + 1]) * i
                res += LENS[j] * (POWER[2 * zz] + POWER[(2 * zz) + 1]) * i
            else:
                c += 2 * LENS[j] * (POWER[zz + j]) * i
                res += 2 * LENS[j] * (POWER[zz + j]) * i
        res %= mod
        cur_len -= 1
        zz -= 1
    return res
        
b = []
for i in a:
    b.append((len(str(i)), i))

# b.sort()
res = 0
for i in b:
    x = get(i[1])
    res += x
    res %= mod
print res