#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define mod1 998244353 
#define inf 1000000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

ll calc(ll n)
{
    ll pow=1,carry=0,val=0,dig=10;
    for(ll j=0;j<dig;j++)
    {
        ll x=n%10;n/=10;
        
        val+=pow*x;
        val%=mod1;
        pow*=10;
        pow%=mod1;
        val+=pow*x;
        val%=mod1;
        pow*=10;
        pow%=mod1;
    }
    return val;
}

int main()
{
    fastio;
    #ifdef APNA_IO
        start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);    
    #endif
 
    ll n;cin>>n;
    ll a[n+1],b[n+1],dig=10;
    for(ll i=1;i<=n;i++)
        cin>>a[i],b[i]=a[i];

    ll sum[dig]={0};
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);

    ll ans=0,hatao=0;
    for(ll i=n;i>=1;i--)
    {
        for(ll j=0;j<dig;j++)
            sum[j]+=b[i]%10,b[i]/=10;

        ans-=calc(a[i]);

        ll pow1=1,carry1=0,val1=0,pow2=1,carry2=0,val2=0;
        for(ll j=0;j<dig;j++)
        {
            ll x=sum[j]+carry1;
            val1+=pow1*(x%10);
            val1%=mod1;
            pow1*=10;
            pow1%=mod1;
            carry1=x/10;

            ll digit=a[i]%10;
            x=(n-i+1)*digit+carry1;
            val1+=pow1*(x%10);
            val1%=mod1;
            pow1*=10;
            pow1%=mod1;
            carry1=x/10;
            a[i]/=10;

            if(!digit)
            {
                x=sum[j]+carry2;
                val2+=pow2*(x%10);
                val2%=mod1;
                pow2*=10;
                pow2%=mod1;
                carry2=x/10;
                continue;
            }

            x=digit*(n-i+1)+carry2;
            val2+=pow2*(x%10);
            val2%=mod1;
            pow2*=10;
            pow2%=mod1;
            carry2=x/10;

            
            x=sum[j]+carry2;
            val2+=pow2*(x%10);
            val2%=mod1;
            pow2*=10;
            pow2%=mod1;
            carry2=x/10;
        }
        val1+=pow1*carry1;
        val1%=mod1;
        val2+=pow2*carry2;
        val2%=mod1;
        ans=(ans+val1+val2)%mod1;
    }
    cout<<ans;

    #ifdef APNA_IO
        end_routine();
    #endif
}
