import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main
{
	static final long mod=998244353;
	public static void main(String[] args) throws Exception
	{
		FastReader in=new FastReader();
		PrintWriter pw=new PrintWriter(System.out);
		int n=in.nextInt();
		int[] arr=new int[n];
		long[] freq=new long[11];
		for(int i=0;i<n;i++)
		{
			arr[i]=in.nextInt();
			int c=0,a=arr[i];
			while(a>0)
			{
				c++;
				a/=10;
			}
			freq[c]++;
		}
		long ans=0;
		for(int i=0;i<n;i++)
		{
			for(int j=1;j<11;j++)
			{
				long a=arr[i],b=1,tans=0;
				int k=j;
				while(a>0 && k>=0)
				{
					long c=a%10;
					ans+=(c*(b*freq[j])%mod)%mod;
					ans%=mod;
					a/=10;
					b*=100;
					k--;
				}
				b/=10;
				while(a>0)
				{
					long c=a%10;
					ans+=(c*(b*freq[j])%mod)%mod;
					ans%=mod;
					a/=10;
					b*=10;
				}
				a=arr[i];
				b=10;
				k=j;
				while(a>0 && k>0)
				{
					long c=a%10;
					ans+=(c*(b*freq[j])%mod)%mod;
					ans%=mod;
					a/=10;
					b*=100;
					k--;
				}
				b/=10;
				while(a>0)
				{
					long c=a%10;
					ans+=(c*(b*freq[j])%mod)%mod;
					ans%=mod;
					a/=10;
					b*=10;
				}
			}
			// pw.println(ans);
		}
		pw.print(ans);
		pw.flush();
	}
}

class FastReader
{
	BufferedReader br;
	StringTokenizer st;

	public FastReader()
	{
	    br=new BufferedReader(new InputStreamReader(System.in));
	}

	public String next() throws IOException
	{
	    if(st==null || !st.hasMoreElements())
	    {
	        st=new StringTokenizer(br.readLine());
	    }
	    return st.nextToken();
	}

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

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