
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.function.Function;

public class P1195D {

    static InputReader in = new InputReader(System.in);

    public static void main(String[] args) {
        final int mod = 998244353;
//        while (true) {
//            int n = in.nextInt();
//            int m = in.nextInt();
//            System.out.println(length(n));
//            System.out.println(length(m));
//            System.out.println(f1(n, m));
//            System.out.println(f2(n, m));
//        }
        int n = in.nextInt();
        long[] arr = in.nextLongArray(n);
        int[] lengths = new int[20];
        for (long a : arr) {
            lengths[length(a)]++;
        }
        for (int i = 0; i < arr.length; i++) {
            long sum = 0;
            for (int j = 0; j < lengths.length; j++) {
                sum += multMod(f1((int) arr[i], j), lengths[j], mod);
                sum += multMod(f2((int) arr[i], j), lengths[j], mod);
                sum %= mod;
            }
            arr[i] = sum;
        }
//        System.out.println(Arrays.toString(lengths));
        System.out.println(sumMod(arr, mod));
    }

    static long f1(int n, int l) {
        long result = 0;
        long m = 1;
        while (n > 0 && l > 0) {
            result += m * (n % 10);
            m *= 100;
            n /= 10;
            l--;
        }
        result += n * m;
        return result;
    }

    static long f2(int n, int l) {
        long result = 0;
        long m = 10;
        l -= 1;
        while (n > 0 && l > 0) {
            result += m * (n % 10);
            m *= 100;
            n /= 10;
            l--;
        }
        result += n * m;
        return result;
    }

    static int length(long n) {
        int l = 0;
        while (n > 0) {
            n /= 10;
            l++;
        }
        return l;
    }

    /* -----: Helper methods :----- */
    public static <R> long binarySearch(long lowerBound, long upperBound,
            R value, Function<Long, R> generatorFunction, Comparator<R> comparator) {
        if (lowerBound <= upperBound) {
            long mid = (lowerBound + upperBound) / 2;
            int compare = comparator.compare(generatorFunction.apply(mid), value);
            if (compare == 0) {
                return mid;
            } else if (compare < 0) {
                return binarySearch(mid + 1, upperBound, value, generatorFunction, comparator);
            } else {
                return binarySearch(lowerBound, mid - 1, value, generatorFunction, comparator);
            }
        } else {
            return -1;
        }
    }

    public static <T> void sortSimultaneously(T[] key, Comparator<T> comparator,
            Object[]... moreArrays) {
        int n = key.length;
        for (Object[] array : moreArrays) {
            if (array.length != n) {
                throw new RuntimeException("Arrays must have equals lengths");
            }
        }
        Integer[] indices = new Integer[n];
        for (int i = 0; i < n; i++) {
            indices[i] = i;
        }
        Comparator<Integer> delegatingComparator = (a, b) -> {
            return comparator.compare(key[a], key[b]);
        };
        Arrays.sort(indices, delegatingComparator);
        reorder(indices, key);
        for (Object[] array : moreArrays) {
            reorder(indices, array);
        }
    }

    static void reorder(Integer[] indices, Object[] arr) {
        if (indices.length != arr.length) {
            throw new RuntimeException("Arrays must have equals lengths");
        }
        int n = arr.length;
        Object[] copy = new Object[n];
        for (int i = 0; i < n; i++) {
            copy[i] = arr[indices[i]];
        }
        System.arraycopy(copy, 0, arr, 0, n);
    }

    static long sumProdMod(long[] a, long b, long mod) {
        long res = 0;
        for (int i = 0; i < a.length; i++) {
            res = (res + multMod(a[i], b, mod)) % mod;
        }
        return res;
    }

    static long sumProdMod(int[] a, int b, long mod) {
        long res = 0;
        for (int i = 0; i < a.length; i++) {
            res = (res + multMod(a[i], b, mod)) % mod;
        }
        return res;
    }

    static long sumProdMod(long[] a, long[] b, long mod) {
        if (a.length != b.length) {
            throw new RuntimeException("Arrays must have equals lengths");
        }
        long res = 0;
        for (int i = 0; i < a.length; i++) {
            res = (res + multMod(a[i], b[i], mod)) % mod;
        }
        return res;
    }

    static long sumProdMod(int[] a, int[] b, long mod) {
        if (a.length != b.length) {
            throw new RuntimeException("Arrays must have equals lengths");
        }
        long res = 0;
        for (int i = 0; i < a.length; i++) {
            res = (res + multMod(a[i], b[i], mod)) % mod;
        }
        return res;
    }

    static long sumMod(long[] a, long mod) {
        long res = 0;
        for (int i = 0; i < a.length; i++) {
            res = (res + a[i] % mod) % mod;
        }
        return res;
    }

    static long sumMod(int[] b, long mod) {
        long res = 0;
        for (int i = 0; i < b.length; i++) {
            res = (res + b[i] % mod) % mod;
        }
        return res;
    }

    static int multMod(int a, int b, int mod) {
        return (int) (1L * a * b % mod);
    }

    static long multMod(long a, long b, long mod) {
        long res = 0;
        a %= mod;
        b %= mod;
        while (b > 0) {
            if ((b & 1) > 0) {
                res = (res + a) % mod;
            }
            a = (a << 1) % mod;
            b >>= 1;
        }
        return res;
    }

    static int[] toPrimitive(Integer[] arr) {
        int[] res = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }

    static long[] toPrimitive(Long[] arr) {
        long[] res = new long[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }

    static int[][] toPrimitive(Integer[][] arr) {
        int[][] res = new int[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toPrimitive(arr[i]);
        }
        return res;
    }

    static long[][] toPrimitive(Long[][] arr) {
        long[][] res = new long[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toPrimitive(arr[i]);
        }
        return res;
    }

    static Integer[] toWrapper(int[] arr) {
        Integer[] res = new Integer[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }

    static Long[] toWrapper(long[] arr) {
        Long[] res = new Long[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }

    static Integer[][] toWrapper(int[][] arr) {
        Integer[][] res = new Integer[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toWrapper(arr[i]);
        }
        return res;
    }

    static Long[][] toWrapper(long[][] arr) {
        Long[][] res = new Long[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toWrapper(arr[i]);
        }
        return res;
    }
}

class InputReader {

    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

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

    public int[] nextIntArray(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }
        return arr;
    }

    public <T> T[] nextIntArray(int n, Function<Integer, T> function, T[] arr) {
        for (int i = 0; i < n; i++) {
            arr[i] = function.apply(nextInt());
        }
        return arr;
    }

    public long[] nextLongArray(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }
        return arr;
    }

    public <T> T[] nextLongArray(int n, Function<Long, T> function, T[] arr) {
        for (int i = 0; i < n; i++) {
            arr[i] = function.apply(nextLong());
        }
        return arr;
    }

    public int[][] nextIntMap(int n, int m) {
        int[][] map = new int[n][m];
        for (int i = 0; i < n; i++) {
            map[i] = nextIntArray(m);
        }
        return map;
    }

    public long[][] nextLongMap(int n, int m) {
        long[][] map = new long[n][m];
        for (int i = 0; i < n; i++) {
            map[i] = nextLongArray(m);
        }
        return map;
    }

    public char[][] nextCharMap(int n) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) {
            map[i] = next().toCharArray();
        }
        return map;
    }

}
