input() # discard n
a = list(map(int, input().split()))
cl = [0]*10
for i in a: cl[len(str(i))-1] += 1
ans, M = 0, 998244353

pad = lambda a, d: a%d + (a - a%d) * 10

for i in a:
    for p,le in enumerate(cl):
        #if le: print(p, 'top is', i*10, le)
        ans = (ans + i*10 * le) % M

        i = pad(i, 10 * 100**p)

        #if le: print(p, 'bottom is', i, le)
        ans = (ans + i * le) % M

print(ans)
