import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CF1195D2 {

    private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
    private static StringTokenizer st;
    private static final long MOD = 998_244_353;

    public static void main(String[] args) throws Exception {
        st = new StringTokenizer(reader.readLine());
        int n = Integer.parseInt(st.nextToken());
        int[] lengths = new int[11];
        int[] numbers = new int[n];
        st = new StringTokenizer(reader.readLine());
        for (int t = 0; t < n; t++) {
            int x = Integer.parseInt(st.nextToken());
            lengths[Integer.toString(x).length()]++;
            numbers[t] = x;
        }

        long sum = 0;
        for (int t = 0; t < n; t++) {
            int x = numbers[t];
            int power = 0;
            while (x > 0) {
                int digit = x % 10;
                x /= 10;
                power++;
                for (int i = 1; i <= 10; i++) {
                    if (power > i) {
                        sum = (sum + 2 * digit * (powerTen(power - 1 + i)) * lengths[i]) % MOD;
                    } else {
                        sum = (sum + digit * (11 * powerTen(2 * power - 2 )) * lengths[i]) % MOD;
                    }
                }
            }
        }
        writer.write(Long.toString(sum));
        writer.newLine();
        writer.flush();
    }

    private static long powerTen(long n) {
        long res = 1;
        for (int i = 0; i < n; i++) {
            res *= 10;
        }
        return res;
    }

}
