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

for i in a:
    for p,le in enumerate(cl):
        ans = (ans + i*10 * le) # bottom zero pad
        d = 10 * 100**p
        i = i%d + (i - i%d) * 10
        ans = (ans + i * le) # top zero pad

print(ans % 998244353)
