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

MOD = 998244353
MOD2 = MOD * MOD

ans = 0

digs = [0] * 11

for i in xrange(n):
    x = a[i]
    d = 0
    while x > 0:
        r = x % 10
        d += 1
        x //= 10

    digs[d] += 1

for i in xrange(n):
    x = 0

    pre = a[i]
    suf = 0

    mul = 10
    for j in xrange(1, 11):
        x += (pre * mul + suf) * digs[j]
        if (x >= MOD2): x %= MOD

        r = pre % 10
        pre //= 10

        suf += (r * mul)
        
        if (pre > 0): mul *= 100
        else: mul = 1

    y = 0

    pre = a[i] // 10
    suf = a[i] % 10

    mul = 100
    for j in xrange(1, 11):        
        y += (pre * mul + suf) * digs[j]
        if (x >= MOD2): x %= MOD

        r = pre % 10
        pre //= 10

        suf += (r * mul)
        
        if (pre > 0): mul *= 100
        else: mul = 1

    ans += (x + y)
    if (ans >= MOD2): ans %= MOD

print ans % MOD