from __future__ import division, print_function

def main():
    from itertools import product
    n = int(input())
    a = input_as_list()
    
    tb = array_of(int, 10, 10)
    cnt = array_of(int, 10)
    
    for e in a:
        s = str(e)
        cnt[len(s)-1] += 1
        for i, c in enumerate(reversed(s)):
            tb[i][int(c)] += 1
    
    out = 0
    for pos, val in product(range(10), repeat=2):
        oc = tb[pos][val]
        for olv in range(10):
            if olv < pos:
                out = (out + 2 * oc * cnt[olv] * val * 10 ** (olv + pos + 1)) % MOD
            else:
                out = (out + 11 * oc * cnt[olv] * val * 10 ** (2*pos)) % MOD
    
    print(out)

INF = float('inf')
MOD = 998244353

import os, sys
from atexit import register
from io import BytesIO
import itertools

if sys.version_info[0] < 3:
    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

if "LOCAL_" in os.environ:
    debug_print = print
else:
    sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
    sys.stdout = BytesIO()
    register(lambda: os.write(1, sys.stdout.getvalue()))

    input = lambda: sys.stdin.readline().rstrip('\r\n')
    debug_print = lambda *x, **y: None


def input_as_list():
    return list(map(int, input().split()))

def array_of(f, *dim):
    return [array_of(f, *dim[1:]) for _ in range(dim[0])] if dim else f()

main()