import java.math.BigInteger;
import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] lineParts = scanner.nextLine().split(" ");
        int n = Integer.parseInt(lineParts[0]);
        long[] arr = new long[n];
        lineParts = scanner.nextLine().split(" ");
        for (int i = 0; i < n; i++) {
            arr[i] = Long.parseLong(lineParts[i]);
        }

        int[] lengthCounts = new int[11];
        int[] digitSums = new int[10];
        for (int i = 0; i < n; i++) {
            long num = arr[i];
            int length = String.valueOf(num).length();
            lengthCounts[length]++;

            char[] digits = String.valueOf(num).toCharArray();
            for (int j = 0; j < digits.length; j++) {
                digitSums[j] += Integer.parseInt(String.valueOf(digits[digits.length - j - 1]));
            }
        }

        long modulo = 998_244_353;
        BigInteger sum = BigInteger.ZERO;

        for (int digitIndex = 0; digitIndex < digitSums.length; digitIndex++) {
            long digitSum = digitSums[digitIndex];

            int power = digitIndex;
            int j = 0;
            for (; j < digitIndex; j++) {
                int count = lengthCounts[j];
                long coefficient = (long)Math.pow(10, power);
                sum = sum.add(BigInteger.valueOf(coefficient).multiply(BigInteger.valueOf(digitSum).multiply(BigInteger.valueOf(count))));
                power++;
            }

            long coefficient = (long)Math.pow(10, power);
            for (; j < lengthCounts.length; j++) {
                int count = lengthCounts[j];
                sum = sum.add(BigInteger.valueOf(coefficient).multiply(BigInteger.valueOf(digitSum).multiply(BigInteger.valueOf(count))));
            }

            power = digitIndex;
            j = 0;
            for (; j <= digitIndex; j++) {
                int count = lengthCounts[j];
                coefficient = (long)Math.pow(10, power);
                sum = sum.add(BigInteger.valueOf(coefficient).multiply(BigInteger.valueOf(digitSum).multiply(BigInteger.valueOf(count))));
                power++;
            }

            coefficient = (long)Math.pow(10, power);
            for (; j < lengthCounts.length; j++) {
                int count = lengthCounts[j];
                sum = sum.add(BigInteger.valueOf(coefficient).multiply(BigInteger.valueOf(digitSum).multiply(BigInteger.valueOf(count))));
            }
        }

        System.out.println(sum.mod(BigInteger.valueOf(modulo)).toString());
    }
}
