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];
        for (int i = 0; i < n; i++) {
            int length = String.valueOf(arr[i]).length();
            lengthCounts[length]++;
        }

        long modulo = 998_244_353;
        long sum = 0;
        for (int i = 0; i < n; i++) {
            long num = arr[i];
            char[] digits = String.valueOf(num).toCharArray();
            for (int digitIndex = 0; digitIndex < digits.length; digitIndex++) {
                int actualDigitIndex = digits.length - digitIndex - 1;
                int digit = Integer.parseInt(String.valueOf(digits[actualDigitIndex]));

                int power = digitIndex;
                int j = 0;
                for (; j < digitIndex; j++) {
                    int count = lengthCounts[j];
                    long coefficient = (long)Math.pow(10, power);
                    sum += coefficient * digit * count;
                    power++;
                }

                long coefficient = (long)Math.pow(10, power);
                for (; j < lengthCounts.length; j++) {
                    int count = lengthCounts[j];
                    sum += coefficient * digit * count;
                }

                power = digitIndex;
                j = 0;
                for (; j <= digitIndex; j++) {
                    int count = lengthCounts[j];
                    coefficient = (long)Math.pow(10, power);
                    sum += coefficient * digit * count;
                    power++;
                }

                coefficient = (long)Math.pow(10, power);
                for (; j < lengthCounts.length; j++) {
                    int count = lengthCounts[j];
                    sum += coefficient * digit * count;
                }

                sum = sum % modulo;
            }
        }

        System.out.println(sum);
    }
}
