import decimal,math
# from decimal import Decimal as co
from collections import Counter,defaultdict
from fractions import gcd
from bisect import bisect_right,bisect_left
decimal.getcontext().prec = 10
# import sys
# sys.setrecursionlimit(1000000)
# co=decimal.Decimal
def ff(a,l):
	mul=10
	ans=0
	lp=a
	i=0
	while(lp!=0):
		i=i+1
		n=lp%10
		lp=lp/10
		ans=ans+n*mul
		if(i<l):
			mul=mul*100
		else:
			mul=mul*10
	return ans			
def ff2(a,l):
	mul=1
	ans=0
	lp=a
	i=0
	while(lp!=0):
		i=i+1
		n=lp%10
		lp=lp/10
		ans=ans+n*mul
		if(i<=l):
			mul=mul*100
		else:
			mul=mul*10
	return ans			

mod=998244353 
# def ff(a):
# 	ans=0
# 	l=list(str(a))
# 	le=len(l)
# 	for i in range(len(l)):
# 		ans=(ans+int(l[i])*(pow(10,2*le - (2*i+1),mod) + pow(10,2*le - (2*i+2),mod)))%mod
# 	# print ans	
# 	return (ans)%mod	
a=[] 
n=int(raw_input())
a = map(int,raw_input().split())
le=[]
for i in a:
	le.append(len(str(i)))
co = Counter(le)	
# print ff2(1234,2)
ans=0
for i in a:
	for j in range(1,11):
		# print
		ans=(ans+ff(i,j)*co[j])%mod
		ans=(ans+ff2(i,j)*co[j])%mod
print ans%mod
	
# for i in a:
# 	# print i
# 	a1=(a1+ff(i))%mod
# print (a1*n)%mod	