import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int T=1;
        while(T-->0)
        {
            int n=input.nextInt();
            int a[]=new int[n];
            int arr[]=new int[11];
            for(int i=0;i<n;i++)
            {
                a[i]=input.nextInt();
                String s=String.valueOf(a[i]);
                int len=s.length();
                for(int j=1;j<=len;j++)
                {
                    arr[j]++;
                }
            }
            long sum=0;
            long m=998244353;
            for(int i=0;i<n;i++)
            {
                String s=String.valueOf(a[i]);
                for(int j=s.length()-1;j>=0;j--)
                {
                    if(j==s.length()-1)
                    {
                        long d=(s.charAt(j)-48);
                        long v=d;
                        v=(v%m*(long)n%m)%m;
                        sum=(sum%m+v)%m;
                    }
                    else
                    {
                        long d=(s.charAt(j)-48);
                        int nu=s.length()-j;
                        int y=0;
                        for(int k=nu-1;k>=1;k--)
                        {
                            int num=arr[k];
                            if(k!=nu-1)
                            {
                                num-=arr[k+1];
                            }
                            long v=(d%m*(long)Math.pow(10,2*(nu-1)-y)%m)%m;
                            v=(v%m*(long)num%m)%m;
                            sum=(sum%m+v%m)%m;
                            y++;
                        }
                    }
                    long d=(s.charAt(j)-48);
                    int nu=s.length()-j;
                    int y=0;
                    for(int k=nu;k>=1;k--)
                    {
                        int num=arr[k];
                        if(k!=nu)
                        {
                            num-=arr[k+1];
                        }
                        long v=(d%m*(long)Math.pow(10,2*nu-1-y)%m)%m;
                        v=(v%m*(long)num%m)%m;
                        sum=(sum%m+v%m)%m;
                        y++;
                    }
                    /*
                    long p1=(long)Math.pow(10,2*(nu-1));
                    long p2=p1*10;
                    long v=(d%m*p1%m)%m;
                    out.println(v);
                    sum=(sum%m+v%m)%m;
                    v=(d%m*p2%m)%m;
                    out.println(v);
                    sum=(sum%m+v%m)%m;

                     */
                }
            }
            out.println(sum);
        }
        out.close();
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        long nextLong()
        {
            return Long.parseLong(next());
        }
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}