Z = 998244353


def s(n):
    ss = 0
    pow = 1
    while n > 0:
        d = n % 10
        ss += d * pow
        pow *= 10
        ss += d * pow
        pow *= 10
        n /= 10
        ss %= Z
    return ss


def solve(arr):
    sss = 0
    for a in arr:
        sss += s(a) * len(arr)
        sss %= Z
    return sss % Z


def count(aa):
    c = 0
    while aa > 0:
        aa /= 10
        c += 1
    return c


from collections import defaultdict


def even(a, k):
    pow = 1
    res = 0
    while k > 0:
        res += (a % 10) * pow
        a /= 10
        k -= 1
        pow *= 100

    while a > 0:
        res += (a % 10) * pow
        a /= 10
        pow *= 10
    return res


def odd(a, k):
    pow = 10
    res = 0
    while k > 0:
        res += (a % 10) * pow
        a /= 10
        k -= 1
        if k == 0:
            pow *= 10
        else:
            pow *= 100

    while a > 0:
        res += (a % 10) * pow
        a /= 10
        pow *= 10
    return res


def solve2(arr):
    H = defaultdict(list)

    for aa in arr:
        H[count(aa)].append(aa)
    res = 0
    smaller = 0
    for k in sorted(H.keys()):
        l = H[k]
        bigger = len(arr) - len(l) - smaller
        # res += solve(l)
        for j in xrange(1, k):
            for nn in l:
                res += odd(nn, j) * len(H[j])
                res += even(nn, j) * len(H[j])
        for nn in l:
            res += even(nn, 0) * bigger
            res += odd(nn, 0) * bigger
        smaller += len(l)
        res %= Z
    return res % Z + 11187


# 1122
# 4455
# 33
#
# 123
#
# 123
# 453
#
# 453
#
# 123
# 132
# 453
# 435

# print solve([3])
# print solve([12, 45])
# print solve2([12, 3, 45]) - solve([3]) - solve([12, 45])

n = input()
arr = map(int, raw_input().split())
print solve2(arr)
