import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args)
	{
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);

		int n =fr.nextInt() ,i ,i_ ,len[] =new int[7] ;	long arr[] =new long[n] ,mod =998244353l ,ans =0l ;

		for (i = 0 ; i<n ; ++i) {
			String s =fr.next() ;	len[s.length()]++ ;	arr[i] =Long.parseLong(s) ;
		}
		for (i =0 ; i<n ; ++i) {
			long sum =0l ,j =1l ;

			for (i_ =1 ; i_<7 ; i_++) {
				sum += (arr[i]%10l)*j ;	ans =(ans + (sum%mod * len[i_])%mod)%mod ;

				ans =(ans + ((sum*10l)%mod * len[i_])%mod)%mod ;

				arr[i] /= 10l ;		j *= 100l ;	ans =(ans + ((arr[i] * (((j%mod)%mod)*2l)%mod)*len[i])%mod)%mod ;
 			}
		}
		op.println(ans);
		op.flush();	op.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();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

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

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