import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    static long mod;

    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        mod = 998244353L;
        int n = sc.nextInt();
        int[] sizes = new int[11];
        String[] nums = new String[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.next();
            sizes[nums[i].length()]++;
        }
        long ans = 0;
        long[] p10 = new long[1000];
        p10[0] = 1;
        for (int i = 1; i <= 999; i++)
            p10[i] = p10[i - 1] * 10 % mod;
        for (int i = 0; i < n; i++) {
            for (int j = nums[i].length() - 1, j1 = 0; j >= 0; j--, j1++) {
                for (int k = 1; k < sizes.length; k++) {
                    if (k == nums[i].length())
                        ans = (ans + ((nums[i].charAt(j) - '0') * p10[j1 * 2] + (nums[i].charAt(j) - '0') * p10[j1 * 2 + 1]) % mod * sizes[k]) % mod;
                    else if (k >= nums[i].length() - j)
                        ans = (ans + ((nums[i].charAt(j) - '0') * p10[j1 * 2] + (nums[i].charAt(j) - '0') * p10[j1 * 2 + 1]) % mod * sizes[k]) % mod;
                    else
                        ans = (ans + (nums[i].charAt(j) - '0') * p10[j1 * 2 - 1 + k] % mod * sizes[k] % mod * 2) % mod;
                }
            }
        }
        pw.print(ans);
        pw.close();
    }
}

class FastScanner {
    static BufferedReader br;
    static StringTokenizer st = new StringTokenizer("");

    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String next() throws IOException {
        while (!st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}