#include<bits/stdc++.h>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define inf 1e18
#define ld long double
#define pb push_back
#define fi first
#define mod 998244353
#define se second
typedef long long int ll;
using namespace std;
ll power(ll a,ll b){
	ll ans=1,i;
	for(i=1;i<=b;i++){
	ans*=a;
	ans%=mod;
	}
	return ans;
}
int main(void){
		#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	fast;
	ll n,i,j,l,ans=0,c;
	cin>>n;
	ll a[n];
	ll len[n]={0};
	map<ll,ll>mp;
	for(i=0;i<n;i++){
		cin>>a[i];
		ll k=a[i];l=0;
		while(k!=0){
			k/=10;
			l++;
		}
		len[i]=l;
		mp[l]++;
	}
	for(i=0;i<n;i++){
		for(j=1;j<=10;j++){
			ll p=a[i];
			if(mp[j]>0){
			if(j<len[i]){
				c=0;
				while(c<j){
					ll x=power(10,2*c+1);
					c++;
					ll add=x*1LL*(p%10);
				
				//	add%=mod;
					add*=mp[j];
						//cout<<add<<endl;
					add%=mod;
					p/=10;
					//cout<<add<<" "<<mp[j]<<endl;
					ans+=add;
					ans%=mod;
				}
				ans+=mp[j]*p*1LL*pow(10,2*j);
				ans%=mod;
				//cout<<ans<<endl;
				c=0;
				p=a[i];
				while(c<j){
					ll x=power(10,2*c);
					c++;
					ll add=x*1LL*(p%10);
					
			//		add%=mod;
					add*=mp[j];
			//		cout<<add<<endl;
					add%=mod;
					p/=10;
					//cout<<add<<" "<<mp[j]<<endl;
					ans+=add;
					ans%=mod;
				}
				ans+=mp[j]*p*1LL*power(10,2*j);
				ans%=mod;
				//cout<<ans<<endl;
			}
			else{
				c=0;
				while(p!=0){
					ll x=power(10,2*c+1);
					x%=mod;
					c++;
					ll add=x*1LL*(p%10);
					
			//		add%=mod;
					add*=mp[j];
					add%=mod;
			//cout<<add<<endl;
					p/=10;
					//cout<<add<<" "<<mp[j]<<endl;
					ans+=add;
					ans%=mod;
				}
				//cout<<ans<<endl;
				p=a[i];
				c=0;
				while(p!=0){
					ll x=power(10,2*c);
					x%=mod;
					c++;
					ll add=x*1LL*(p%10);
					
			//		add%=mod;
					add*=mp[j];
					add%=mod;
					p/=10;
					//cout<<add<<" "<<mp[j]<<endl;
					ans+=add;
					ans%=mod;
				}
				//cout<<ans<<endl;
			}
			}
		}
	}
	//cout<<LLONG_MAX<<endl;
	cout<<ans<<endl;
}
