/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
*/
import java.util.*;
import java.io.*;

   public class D2b
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         long[] arr = new long[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Long.parseLong(st.nextToken());
         //buckets
         long MOD = 998244353L;
         long[] bucket = new long[11];
         long[] count = new long[11];
         for(long ax: arr)
         {
            long a = ax;
            int assign = (int)(Math.log(a)/Math.log(10))+1;
            count[assign]++;
            bucket[assign] += ax;
            bucket[assign] %= MOD;
         }
         //bash
         long res = 0L;
         for(int c1=1; c1 <= 10; c1++)
            for(int c2=1; c2 <= 10; c2++)
            {
               long v1 = bucket[c1];
               long v2 = bucket[c2];
               //c1 first
               long pow = 0;
               boolean b = false;
               while(v1 > 0 && v2 > 0)
               {
                  res += (v1%10)*power(10, pow, MOD);
                  res %= MOD;
                  res += (v2%10)*power(10, pow+1, MOD);
                  res %= MOD;
                  pow+=2;
                  v1 /= 10;
                  v2 /= 10;
                  b = true;
               }
               //over
               if((v1 > 0 || v2 > 0)&&b)
               {
                  long flap = Math.max(v1, v2);
                  res += flap*power(10, pow, MOD);
                  res %= MOD;
               }
               //pray
            }
         //yeet them double
         for(int c2=1; c2 <= 10; c2++)
         {
            long v1 = bucket[c2];
            long v2 = bucket[c2];
            //c1 first
            long pow = 0;
            boolean b = false;
            while(v1 > 0 && v2 > 0)
            {
               res += (v1%10)*power(10, pow, MOD);
               res %= MOD;
               res += (v2%10)*power(10, pow+1, MOD);
               res %= MOD;
               pow+=2;
               v1 /= 10;
               v2 /= 10;
               b = true;
            }
            //over
            if((v1 > 0 || v2 > 0)&&b)
            {
               long flap = Math.max(v1, v2);
               res += flap*power(10, pow, MOD);
               res %= MOD;
            }
            //pray
         }
         System.out.println(res%MOD);
      }
      public static long power(long x, long y, long p) 
       { 
           // Initialize result 
           long res = 1L;      
            
           // Update x if it is more   
           // than or equal to p 
           x = x % p;  
         
           while (y > 0L) 
           { 
               // If y is odd, multiply x 
               // with result 
               if((y & 1)==1) 
                   res = (res * x) % p; 
         
               // y must be even now 
               // y = y / 2 
               y = y >> 1;  
               x = (x * x) % p;  
           } 
           return res; 
       } 
      public static void sort(int[] arr)
      {
         PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
         for(int a: arr)
            pq.add(a);
         for(int i=0; i < arr.length; i++)
            arr[i] = pq.poll();
      }
   }