mod = 998244353

def main():

    n = int(input())
    A = list(map(int, input().split()))

    N = 10**6
    table = [0]*(N+1)
    table[0] = 1
    for i in range(1, N+1):
        table[i] = table[i-1]*10
        table[i] %= mod

    C = [0]*11
    for a in A:
        C[len(str(a))] += 1

    ans = 0
    for i, a in enumerate(A):
        a = str(a)
        a = list(a)
        a.reverse()
        for j, c in enumerate(a):
            c = int(c)
            for k in range(11):
                if k <= j:
                    ans += c*table[2*j+1-(j-k+1)]*C[k]
                else:
                    ans += c*table[2*j+1]*C[k]
            for k in range(11):
                if k <= j-1:
                    ans += c*table[2*j-(j-k)]*C[k]
                else:
                    ans += c*table[2*j]*C[k]
            ans %= mod
    print(ans)

if __name__ == '__main__':
    main()
