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

public class CF1195D2 extends PrintWriter {
	CF1195D2() { super(System.out, true); }
	static class Scanner {
		Scanner(InputStream in) { this.in = in; } InputStream in;
		int k, l; byte[] bb = new byte[1 << 15];
		byte getc() {
			if (k >= l) {
				k = 0;
				try { l = in.read(bb); } catch (IOException e) { l = 0; }
				if (l <= 0) return -1;
			}
			return bb[k++];
		}
		int nextInt() {
			byte c = 0; while (c <= 32) c = getc();
			int a = 0;
			while (c > 32) { a = a * 10 + c - '0'; c = getc(); }
			return a;
		}
	}
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1195D2 o = new CF1195D2(); o.main(); o.flush();
	}

	static final int MD = 998244353;
	void main() {
		int n = sc.nextInt();
		int[] aa = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = sc.nextInt();
		int[] ll = new int[n];
		int[] kk = new int[11];
		for (int i = 0; i < n; i++) {
			int l = 0;
			for (int a = aa[i]; a > 0; a /= 10)
				l++;
			ll[i] = l;
			kk[l]++;
		}
		int[] pp = new int[20];
		long p = 1;
		for (int l = 0; l < 20; l++) {
			pp[l] = (int) p;
			p = p * 10 % MD;
		}
		long ans = 0;
		for (int i = 0; i < n; i++) {
			int l = ll[i];
			int a = aa[i];
			for (int u = 1; u <= l; u++) {
				int d = a % 10;
				for (int v = 1; v <= 10; v++)
					if (kk[v] > 0) {
						int o = u - 1 + Math.min(u, v);
						int e = u - 1 + Math.min(u - 1, v);
						ans = (int) (ans + (long) d * (pp[o] + pp[e]) % MD * kk[v] % MD);
					}
				a /= 10;
			}
		}
		println(ans);
	}
}
