#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(v) v.begin(),v.end()
#define mod 998244353 
#define N 200010
#define inf 100000000000 
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int digits(int n)
{
    int cnt=0;
    while(n>0)
    {
        cnt++;
        n/=10;
    }
    return cnt;
}

signed main()
{
    fast
    int n;
    cin>>n;
    vector<int> v(n),len(12,0);
    
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        len[digits(v[i])]++;
    }
    
    
    vector<int> power(19);
    power[0]=1;
    for(int i=1;i<19;i++)
    {
        power[i]=(power[i-1]*10)%mod;
    }
    
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=11;j++)
        {
            if(len[j]>0)
            {
                int curr_p=0,curr_n=0;
                int x=v[i];
                while(x>0)
                {
                    int rem=x%10;
                    ans+=((power[curr_p]*rem)%mod)*len[j];
                    ans=ans%mod;
                    if(j>curr_n)
                    {
                        curr_p++;
                    }
                    ans+=((power[curr_p]*rem)%mod)*len[j];
                    ans=ans%mod;
                    curr_p++;
                    x/=10;
                    curr_n++;
                }
            }
        }
    }
    cout<<ans;
    
    
    /*
    for(int i=0;i<11;i++)
    {
        cout<<i<<" "<<len[i]<<"\n";
    }*/
    
}