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

//CHECK LIMITS U RARTED DUMBO - 10^8 too SLO for BF
//FIND PATTERN IF TOO SLOW FOR BRUTE FORCE
//CHECK ALL PARAMETERS
//MAKE SURE YOU FIGURE OUT WHICH YOU USE (int vs ll)
//WRITE SOL ON PAPER BFR IMPLEMENTING
public class D {

	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {

		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		} else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}

		Solver solver = new Solver();
		solver.solve(br, pw);
	}

	static class Solver {
		static long mod = 998244353L;

		public void solve(FastScanner br, PrintWriter pw) throws IOException {
			int n = br.nextInt();
			long[] cnts = new long[12];
			long[] vals = new long[n];
			for (int i = 0; i < n; i++) {
				long l = br.nextLong();
				vals[i] = l;
				int counter = 0;
				while (l != 0L) {
					l = l / 10;
					counter++;
				}
				cnts[counter]++;
			}
			long out = 0;
			for (int i = 0; i < n; i++) {
				for (int j = 1; j < 12; j++) {
					if(cnts[j]==0)
						continue;
					int counter = 0;
					long l = vals[i];
					long a = 0;
					long b = 0;
					a += ((l % 10) * (pow(10, counter * 2)) % mod) % mod;
					while (l != 0L && counter < j) {
						b += ((l % 10) * (pow(10, (counter) * 2 + 1)) % mod) % mod;
						l = l / 10;
						counter++;
						a += ((l % 10) * (pow(10, counter * 2)) % mod) % mod;
					}
					while (l != 0L) {
						b += ((l % 10) * (pow(10, counter+1)) % mod) % mod;
						l = l / 10;
						counter++;
						a += ((l % 10) * (pow(10, counter)) % mod) % mod;
					}
					//System.out.println(a + ": " + j);
					//System.out.println(b + ": " + j);
					out += (a*cnts[j])%mod;
					out += (b*cnts[j])%mod;
				}
			}
			pw.println(out % mod);
			pw.close();
		}

		static long pow(long a, long b) {
			if (b == 0)
				return 1L;
			long val = pow(a, b / 2);
			if (b % 2 == 0)
				return val * val % mod;
			else
				return val * val % mod * a % mod;
		}

	}

	static class Point implements Comparable<Point> {
		int a;
		int b;

		Point(int a, int b) {
			this.a = a;
			this.b = b;
		}

		@Override
		public int compareTo(Point o) {
			return this.a - o.a;
		}

	}

	static class Dsu {
		int n;
		int[] parent;
		int[] rank;

		public Dsu(int n) {
			this.n = n;
			parent = new int[n];
			rank = new int[n];
		}

		public void createSet() {
			for (int i = 0; i < n; i++) {
				parent[i] = i;
				rank[i] = 0;
			}
		}

		public int findParent(int x) {
			if (parent[x] == x)
				return x;
			parent[x] = findParent(parent[x]);
			return parent[x];
		}

		public void mergeSet(int a, int b) {
			int pa = findParent(a);
			int pb = findParent(b);

			if (pa == pb)
				return;

			if (rank[pa] > rank[pb]) {
				parent[pb] = pa;
			} else if (rank[pa] < rank[pb]) {
				parent[pa] = pb;
			} else {
				parent[pb] = pa;
				rank[pa]++;
			}
		}
	}

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

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

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}

		ArrayList<Integer>[] nextGraph(int nodes, int edges) {
			ArrayList<Integer>[] adj = new ArrayList[nodes];
			for (int i = 0; i < nodes; i++) {
				adj[i] = new ArrayList<Integer>();
			}
			for (int i = 0; i < edges; i++) {
				int a = nextInt() - 1;
				int b = nextInt() - 1;
				adj[a].add(b);
				adj[b].add(a);
			}
			return adj;
		}
	}
}