
import sys,os,math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat



# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())


def main():
    n = map(int, raw_input().split())[0]
    da = map(int, raw_input().split())
    def get(num, p):
        re = num%10
        num /= 10
        st = 100 if p else 10
        p -= 1
        while num:
            re += num%10 * st
            num/=10
            st*= 100 if p else 10
            if p:
                p -= 1
        return re
    co = defaultdict(int)
    for i in da:
        co[len(str(i))] += 1
    sj = [0 for i in range(12)]
    for jj in range(1, 11):
        for i in da:
            sj[jj] += get(i, jj)
            sj[jj] %= 998244353
    ans = 0
    for i in da:
        le = len(str(i))
        for jj in range(11):
            # print get(i, jj-1), i ,jj
            ans += get(i, jj-1) * 10 * co[jj]
            ans %= 998244353
        ans += sj[le]
    print ans

main()
