import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] sa = br.readLine().split(" "); Arrays.sort(sa); long[] a = new long[n]; for (int i = 0; i < n; i++) { a[i] = Long.parseLong(sa[i]); } br.close(); int mod = 998244353; long[] b = new long[20]; b[0] = 1; for (int i = 1; i < b.length; i++) { b[i] = b[i - 1] * 10; b[i] %= mod; } long ans = 0; for (int i = 0; i < n; i++) { ans *= b[sa[i].length()]; ans += a[i]; ans %= mod; } System.out.println(ans); } }