from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log, pi, e, asin,acos, cos, sin, floor, atan
from itertools import *
from fractions import Fraction
import string
import copy
import random
import bisect
from decimal import *
from collections import deque
from sys import *
digs = string.digits + string.ascii_letters

def id_generator(size=20, chars='ABCDEFGHIJ'):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).strip().split())

clear=stdout.flush()

mod = 998244353 

n=input()
l=list(mp())

ans=0
z=[0 for i in range(11)]
for i in range(n):
	x=str(l[i])
	z[len(x)]+=1

for i in range(n):
	x=l[i]
	x=str(x)
	x=x[::-1]
	for j in range(1,11):
		a=''
		b=''
		if len(x)<j:
			for i in x:
				a+='0'
				a+=i
				b+='0'
				b+=i
			b=b[1:]
			a=a[::-1]
			b=b[::-1]	
		else:
			k=0
			while k<len(x):
				if k<j:
					a+='0'
					a+=x[k]
					b+='0'
					b+=x[k]
				elif k<=j:
					b+='0'
					b+=x[k]
					a+=x[k]
				else:
					a+=x[k]
					b+=x[k]
				k+=1
			b=b[1:]
			a=a[::-1]
			b=b[::-1]	
		a=int(a)
		b=int(b)
		# print a, b, z[j], j
		ans=(ans+(a+b)*z[j])%mod

print ans