using System;

class Fffuuuu {

    Boolean MG(String str) {
        return str.EndsWith("lios") || str.EndsWith("etr") || str.EndsWith("inits");
    }

    Boolean Pril(String str) {
        return str.EndsWith("lios") || str.EndsWith("liala");
    }

    Boolean Sush(String str) {
        return str.EndsWith("etr") || str.EndsWith("etra");
    }

    Boolean Glag(String str) {
        return str.EndsWith("initis") || str.EndsWith("inites");
    }

    Boolean Check(String text) {
        String[] tok = text.Split(new Char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        Boolean mg = MG(tok[0]);
        foreach (String s in tok) {
            if (MG(s) != mg) {
                return false;
            }
        }
        Int32 j = Array.FindIndex(tok, Sush);
        if (j < 0) {
            return false;
        }
        for (Int32 i = 0; i < j; ++i) {
            if (!Pril(tok[i])) {
                return false;
            }
        }
        for (Int32 i = j + 1; i < tok.Length; ++i) {
            if (!Glag(tok[i])) {
                return false;
            }
        }
        return true;
    }

    public Fffuuuu() {
        Console.WriteLine(Check(Console.ReadLine()) ? "YES" : "NO");
    }

    public static void Main() {
#if DEBUG
        Console.SetIn(new System.IO.StreamReader("in.txt"));
#endif
        new Fffuuuu();
    }

}


using System;

class Fffuuuu {

    Boolean MG(String str) {
        return str.EndsWith("lios") || str.EndsWith("etr") || str.EndsWith("initis");
    }

    Boolean Pril(String str) {
        return str.EndsWith("lios") || str.EndsWith("liala");
    }

    Boolean Sush(String str) {
        return str.EndsWith("etr") || str.EndsWith("etra");
    }

    Boolean Glag(String str) {
        return str.EndsWith("initis") || str.EndsWith("inites");
    }

    Boolean Check(String text) {
        String[] tok = text.Split(new Char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        Boolean mg = MG(tok[0]);
        foreach (String s in tok) {
            if (MG(s) != mg) {
                return false;
            }
        }
        if (tok.Length == 1) {
            return true;
        }
        Int32 j = Array.FindIndex(tok, Sush);
        if (j < 0) {
            return false;
        }
        for (Int32 i = 0; i < j; ++i) {
            if (!Pril(tok[i])) {
                return false;
            }
        }
        for (Int32 i = j + 1; i < tok.Length; ++i) {
            if (!Glag(tok[i])) {
                return false;
            }
        }
        return true;
    }

    public Fffuuuu() {
        Console.WriteLine(Check(Console.ReadLine()) ? "YES" : "NO");
    }

    public static void Main() {
#if DEBUG
        Console.SetIn(new System.IO.StreamReader("in.txt"));
#endif
        new Fffuuuu();
    }

}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = int(1e5) + 10;
const int mod = 998244353;
string a[N];
LL tenpow[20];
int len[N];
int main(){
    tenpow[0]=1;
    for(int i=1;i<=10;i++){
        tenpow[i]=tenpow[i-1]*10%mod;
    }
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string t;cin>>t;
        reverse(t.begin(), t.end());
        len[t.size()]++;
        a[i]=t;
    }
    LL ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<a[i].size();j++){
            for(int k=1;k<=10;k++){
                int x=(a[i][j]-'0')*tenpow[j+min(k,j)]*len[k];
                x %= mod;
                int y=(a[i][j]-'0')*tenpow[j+min(j+1,k)]*len[k];
                y %= mod;
                ans += x+y;
                ans %= mod;
            }
        }
    }
    cout<<ans<<endl;
}


#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;
const int N = int(1e5) + 10;
const int mod = 998244353;
string a[N];
int len[20];
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    LL ans=0;
    for(int i=1;i<=n;i++) len[a[i].size()]++;
    for(int i=9;i>=1;i--) len[i]+=len[i+1];
    for(int j=1;j<=n;j++){
        LL t=11,tmp=0;
        int o=1;
        for(int i=a[j].size()-1;i>=0;i--){
            tmp=(tmp+(((a[j][i]-'0')*len[o++])%mod*t)%mod)%mod;
            t*=100;
        }
        ans=(ans+tmp)%mod;
    }
    cout<<ans<<endl;
//    for(int i=a[1].size()-1;i>=0;i--){
//        LL tmp=0;
//        int p=0;
//        for(int j=1;j<=n;j++){
//            tmp+=a[j][i]-'0';
//        }
//        tmp=tmp*n%mod;
//        tmp=tmp*t%mod;
//        ans=(ans+tmp)%mod;
//        t=(t*100)%mod;
//    }
//    cout<<ans%mod<<endl;
}


#include<cstdio>
#include<cstdlib>

#define ll long long
const ll mod=998244353;

int main()
{
    int n;
    scanf("%d",&n);
    ll *a=(ll *) malloc((n+2)*sizeof(ll));
    ll *cnt=(ll *) calloc(11,sizeof(ll));

    for (int i=0;i<n;i++)
        scanf("%lld",&a[i]);

    for (int i=0;i<n;i++)
    {
        ll d=a[i],br=0;

        while (d)
            d/=10, br++;

        cnt[br]++;
    }

    //for (int i=1;i<=10;i++) printf("%d ",cnt[i]);
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        ll d=a[i], br=0,p=1;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br+=p*(d%10);
                d/=10;
                p=p*100;

                ans=(ans+ ((((d*p)%mod+br))%mod*cnt[j])%mod)%mod;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;
        }

        d=a[i], br=0, p=10;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br+=p*(d%10);
                d/=10;
                ans=(ans+((( (d*(p*10))%mod+br)%mod)*cnt[j])%mod)%mod;
                p*=100;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;

        }

    }
    printf("%lld",ans);
    free(a);
    free(cnt);
    return 0;
}


#include<cstdio>
#include<cstdlib>

#define ll long long
const ll mod=998244353;

int main()
{
    int n;
    scanf("%d",&n);
    ll *a=(ll *) malloc((n+2)*sizeof(ll));
    ll *cnt=(ll *) calloc(11,sizeof(ll));

    for (int i=0;i<n;i++)
        scanf("%lld",&a[i]);

    for (int i=0;i<n;i++)
    {
        ll d=a[i],br=0;

        while (d)
            d/=10, br++;

        cnt[br]++;
    }

    //for (int i=1;i<=10;i++) printf("%d ",cnt[i]);
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        ll d=a[i], br=0,p=1;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br+=p*(d%10);
                d/=10;
                if (p<=1000000000000000) p*=100;

                ans=(ans+ ((((d*p)%mod+br))%mod*cnt[j])%mod)%mod;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;
        }

        d=a[i], br=0, p=10;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br+=p*(d%10);
                d/=10;
                ans=(ans+((( (d*(p*10))%mod+br)%mod)*cnt[j])%mod)%mod;
                if (p<=1000000000000000) p*=100;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;

        }

    }
    printf("%lld",ans);
    free(a);
    free(cnt);
    return 0;
}


#include<cstdio>
#include<cstdlib>

#define ll long long
const ll mod=998244353;

int main()
{
    int n;
    scanf("%d",&n);
    ll *a=(ll *) malloc((n+2)*sizeof(ll));
    ll *cnt=(ll *) calloc(11,sizeof(ll));

    for (int i=0;i<n;i++)
        scanf("%lld",&a[i]);

    for (int i=0;i<n;i++)
    {
        ll d=a[i],br=0;

        while (d)
            d/=10, br++;

        cnt[br]++;
    }

    //for (int i=1;i<=10;i++) printf("%d ",cnt[i]);
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        ll d=a[i], br=0,p=1;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br+=p*(d%10);
                d/=10;
                p*=100;

                ans=(ans+ ((d*p+br)*cnt[j])%mod)%mod;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;
        }

        d=a[i], br=0, p=10;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br+=p*(d%10);
                d/=10;
                ans=(ans+((d*(p*10)+br)*cnt[j])%mod)%mod;
                p*=100;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;

        }

    }
    printf("%lld",ans);
    free(a);
    free(cnt);
    return 0;
}


#include<cstdio>
#include<cstdlib>

#define ll long long
const ll mod=998244353;

int main()
{
    int n;
    scanf("%d",&n);
    ll *a=(ll *) malloc((n+2)*sizeof(ll));
    ll *cnt=(ll *) calloc(11,sizeof(ll));

    for (int i=0;i<n;i++)
        scanf("%lld",&a[i]);

    for (int i=0;i<n;i++)
    {
        ll d=a[i],br=0;

        while (d)
            d/=10, br++;

        cnt[br]++;
    }

    //for (int i=1;i<=10;i++) printf("%d ",cnt[i]);
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        ll d=a[i], br=0,p=1;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br=(br+(p*(d%10))%mod)%mod;
                d/=10;
                //if (p<=1000000000000000) p*=100;

                ans=(ans+ ( (((d*p)%mod+br)%mod)*cnt[j])%mod)%mod;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;
        }

        d=a[i], br=0, p=10;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br=(br+(p*(d%10))%mod)%mod;
                d/=10;
                ans=(ans+((( (d*(p*10))%mod+br)%mod)*cnt[j])%mod)%mod;
                //if (p<=1000000000000000) p*=100;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;

        }

    }
    printf("%lld",ans);
    free(a);
    free(cnt);
    return 0;
}


#include<cstdio>
#include<cstdlib>

#define ll long long
const ll mod=998244353;

int main()
{
    int n;
    scanf("%d",&n);
    ll *a=(ll *) malloc((n+2)*sizeof(ll));
    ll *cnt=(ll *) calloc(11,sizeof(ll));

    for (int i=0;i<n;i++)
        scanf("%lld",&a[i]);

    for (int i=0;i<n;i++)
    {
        ll d=a[i],br=0;

        while (d)
            d/=10, br++;

        cnt[br]++;
    }

    //for (int i=1;i<=10;i++) printf("%d ",cnt[i]);
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        ll d=a[i], br=0,p=1;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br=(br+(p*(d%10))%mod)%mod;
                d/=10;
                //if (p<=1000000000000000)
                p*=100;

                ans=(ans+ ( (((d*p)%mod+br)%mod)*cnt[j])%mod)%mod;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;
        }

        d=a[i], br=0, p=10;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br=(br+(p*(d%10))%mod)%mod;
                d/=10;
                ans=(ans+((( (d*(p*10))%mod+br)%mod)*cnt[j])%mod)%mod;
                //if (p<=1000000000000000)
                p*=100;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;

        }

    }
    printf("%lld",ans);
    free(a);
    free(cnt);
    return 0;
}


#include<cstdio>
#include<cstdlib>

#define ll long long
const ll mod=998244353;

int main()
{
    int n;
    scanf("%d",&n);
    ll *a=(ll *) malloc((n+2)*sizeof(ll));
    ll *cnt=(ll *) calloc(11,sizeof(ll));

    for (int i=0;i<n;i++)
        scanf("%lld",&a[i]);

    for (int i=0;i<n;i++)
    {
        ll d=a[i],br=0;

        while (d)
            d/=10, br++;

        cnt[br]++;
    }

    //for (int i=1;i<=10;i++) printf("%d ",cnt[i]);
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        ll d=a[i], br=0,p=1;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br=(br+(p*(d%10))%mod)%mod;
                d/=10;
                if (p<=1000000000000000) p*=100;

                ans=(ans+ ( (((d*p)%mod+br)%mod)*cnt[j])%mod)%mod;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;
        }

        d=a[i], br=0, p=10;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br=(br+(p*(d%10))%mod)%mod;
                d/=10;
                ans=(ans+((( (d*(p*10))%mod+br)%mod)*cnt[j])%mod)%mod;
                if (p<=1000000000000000) p*=100;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;

        }

    }
    printf("%lld",ans);
    free(a);
    free(cnt);
    return 0;
}


#include<cstdio>
#include<cstdlib>

#define ll long long
const ll mod=998244353;

int main()
{
    int n;
    scanf("%d",&n);
    ll *a=(ll *) malloc((n+2)*sizeof(ll));
    ll *cnt=(ll *) calloc(11,sizeof(ll));

    for (int i=0;i<n;i++)
        scanf("%lld",&a[i]);

    for (int i=0;i<n;i++)
    {
        ll d=a[i],br=0;

        while (d)
            d/=10, br++;

        cnt[br]++;
    }

    //for (int i=1;i<=10;i++) printf("%d ",cnt[i]);
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        ll d=a[i], br=0,p=1;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br=(br+(p*(d%10))%mod)%mod;
                d/=10;
                //if (p<=1000000000000000)
                p=(p*100)%mod;

                ans=(ans+ ( (((d*p)%mod+br)%mod)*cnt[j])%mod)%mod;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;
        }

        d=a[i], br=0, p=10;
        for (int j=1;j<=10;j++)
        {
            if (d)
            {
                br=(br+(p*(d%10))%mod)%mod;
                d/=10;
                ans=(ans+((( (d*((p*10)%mod))%mod+br)%mod)*cnt[j])%mod)%mod;
                //if (p<=1000000000000000)
                p=(p*100)%mod;
            }
            else ans=(ans+(br*cnt[j])%mod)%mod;

        }

    }
    printf("%lld",ans);
    free(a);
    free(cnt);
    return 0;
}


#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<list>
#include<algorithm>
#include<time.h>
#include<sstream>
using namespace std;
long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a%b); }
const long long inf = 0x7f7f7f7f;
const long long mod = 1e9 + 7;
double pi = acos(-1.0);
long long a[20][20];
string str[120000];
long long b[20];
long long Mod = 998244353;
long long quick_mod(long long a, long long b)
{
	long long ans = 1;
	while (b)
	{
		if (b & 1)
			ans = ans * a%Mod;
		b >>= 1;
		a = a * a%Mod;
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> str[i];
		int len = str[i].length();
		for (int j = 0; j < str[i].length(); j++)
		{
			long long t = str[i][j] - '0';
			ans = (ans + t * (quick_mod(10, (len - j - 1) * 2 + 1) + quick_mod(10, (len - j - 1) * 2))) % Mod;
		}
		b[len]++;
		for (int j = 0; j < len; j++)
			a[len][j] += (str[i][j] - '0');
	}
	for (int i = 1; i <= 9; i++)
	{
		if (b[i] == 0)
			continue;
		for (int j = 1; j <= 9; j++)
		{
			if (b[j] == 0)
				continue;
			if (i == j)
			{
				for (int k = 0; k < i; k++)
				{
					long long t = a[i][k];
					ans = (ans + ((b[i] - 1)*(t * (quick_mod(10, (i - k - 1) * 2 + 1) + quick_mod(10, (i - k - 1) * 2)) % Mod)) % Mod) % Mod;
				}
			}
			else if (i > j)
			{
				int len = i - 1;
				int num = 0;
				for (int k = j - 1; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][k] * quick_mod(10, num) + b[j] * a[i][len--] * quick_mod(10, num + 1)) % Mod)) % Mod) % Mod, num += 2;
				for (int k = len; k >= 0; k--)
					ans = (ans + (((b[j] * a[i][k] * quick_mod(10, num)) % Mod)) % Mod) % Mod, num++;
			}
			else
			{
				int len = j - 1;
				int num = 0;
				for (int k = i - 1; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][len--] * quick_mod(10, num) + b[j] * a[i][k] * quick_mod(10, num + 1)) % Mod)) % Mod) % Mod, num += 2;
				for (int k = len; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][k] * quick_mod(10, num)) % Mod)) % Mod) % Mod, num++;
			}
		}
	}
	cout << ans << endl;
}


#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<list>
#include<algorithm>
#include<time.h>
#include<sstream>
using namespace std;
long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a%b); }
const long long inf = 0x7f7f7f7f;
const long long mod = 1e9 + 7;
double pi = acos(-1.0);
long long a[10][10];
string str[120000];
long long b[10];
long long Mod = 998244353;
long long quick_mod(long long a, long long b)
{
	long long ans = 1;
	while (b)
	{
		if (b & 1)
			ans = ans * a%Mod;
		b >>= 1;
		a = a * a%Mod;
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> str[i];
		int len = str[i].length();
		for (int j = 0; j < str[i].length(); j++)
		{
			long long t = str[i][j] - '0';
			ans = (ans + t * (quick_mod(10, (len - j - 1) * 2 + 1) + quick_mod(10, (len - j - 1) * 2))) % Mod;
		}
		b[str[i].length()]++;
		for (int j = 0; j < len; j++)
			a[len][j] += (str[i][j] - '0');
	}
	for (int i = 1; i <= 9; i++)
	{
		if (b[i] == 0)
			continue;
		for (int j = 1; j <= 9; j++)
		{
			if (b[j] == 0)
				continue;
			if (i == j)
			{
				for (int k = 0; k < i; k++)
				{
					long long t = a[i][k];
					ans = (ans + ((b[i] - 1)*(t * (quick_mod(10, (i - k - 1) * 2 + 1) + quick_mod(10, (i - k - 1) * 2)) % Mod)) % Mod) % Mod;
				}
			}
			else if (i > j)
			{
				int len = i - 1;
				int num = 0;
				for (int k = j - 1; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][k] * quick_mod(10, num) + b[j] * a[i][len--] * quick_mod(10, num + 1)) % Mod)) % Mod) % Mod, num += 2;
				for (int k = len; k >= 0; k--)
					ans = (ans + (((b[j] * a[i][k] * quick_mod(10, num)) % Mod)) % Mod) % Mod, num++;
			}
			else
			{
				int len = j - 1;
				int num = 0;
				for (int k = i - 1; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][len--] * quick_mod(10, num) + b[j] * a[i][k] * quick_mod(10, num + 1)) % Mod)) % Mod) % Mod, num += 2;
				for (int k = len; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][k] * quick_mod(10, num)) % Mod)) % Mod) % Mod, num++;
			}
		}
	}
	cout << ans << endl;
}


#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<list>
#include<algorithm>
#include<time.h>
#include<sstream>
using namespace std;
long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a%b); }
const long long inf = 0x7f7f7f7f;
const long long mod = 1e9 + 7;
double pi = acos(-1.0);
long long a[20][20];
string str[120000];
long long b[20];
long long Mod = 998244353;
long long quick_mod(long long a, long long b)
{
	long long ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % Mod;
		b >>= 1;
		a = (a * a) % Mod;
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> str[i];
		int len = str[i].length();
		for (int j = 0; j < str[i].length(); j++)
		{
			long long t = str[i][j] - '0';
			ans = (ans + t * (quick_mod(10, (len - j - 1) * 2 + 1) + quick_mod(10, (len - j - 1) * 2))) % Mod;
		}
		b[len]++;
		for (int j = 0; j < len; j++)
			a[len][j] += (str[i][j] - '0');
	}
	for (int i = 1; i <= 10; i++)
	{
		if (b[i] == 0)
			continue;
		for (int j = 1; j <= 10; j++)
		{
			if (b[j] == 0)
				continue;
			if (i == j)
			{
				int num = i * 2 - 1;
				for (int k = 0; k < i; k++)
				{
					long long t = a[i][k];
					ans = (ans + ((b[i] - 1)*(t * (quick_mod(10, num) + quick_mod(10, num - 1)) % Mod)) % Mod) % Mod, num -= 2;
				}
			}
			else if (i > j)
			{
				int len = i - 1;
				int num = 0;
				for (int k = j - 1; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][k] * quick_mod(10, num) % Mod + b[j] * a[i][len--] * quick_mod(10, num + 1) % Mod) % Mod)) % Mod) % Mod, num += 2;
				for (int k = len; k >= 0; k--)
					ans = (ans + (((b[j] * a[i][k] * quick_mod(10, num)) % Mod)) % Mod) % Mod, num++;
			}
			else
			{
				int len = j - 1;
				int num = 0;
				for (int k = i - 1; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][len--] * quick_mod(10, num) % Mod + b[j] * a[i][k] * quick_mod(10, num + 1) % Mod) % Mod)) % Mod) % Mod, num += 2;
				for (int k = len; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][k] * quick_mod(10, num)) % Mod)) % Mod) % Mod, num++;
			}
		}
	}
	cout << ans % Mod << endl;
}


#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<list>
#include<algorithm>
#include<time.h>
#include<sstream>
using namespace std;
long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a%b); }
const long long inf = 0x7f7f7f7f;
const long long mod = 1e9 + 7;
double pi = acos(-1.0);
long long a[20][20];
string str[120000];
long long b[20];
long long Mod = 998244353;
long long quick_mod(long long a, long long b)
{
	long long ans = 1;
	while (b)
	{
		if (b & 1)
			ans = ans * a%Mod;
		b >>= 1;
		a = a * a%Mod;
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> str[i];
		int len = str[i].length();
		for (int j = 0; j < str[i].length(); j++)
		{
			long long t = str[i][j] - '0';
			ans = (ans + t * (quick_mod(10, (len - j - 1) * 2 + 1) + quick_mod(10, (len - j - 1) * 2))) % Mod;
		}
		b[len]++;
		for (int j = 0; j < len; j++)
			a[len][j] += (str[i][j] - '0');
	}
	for (int i = 1; i <= 9; i++)
	{
		if (b[i] == 0)
			continue;
		for (int j = 1; j <= 9; j++)
		{
			if (b[j] == 0)
				continue;
			if (i == j)
			{
				int num = i * 2 - 1;
				for (int k = 0; k < i; k++)
				{
					long long t = a[i][k];
					ans = (ans + ((b[i] - 1)*(t * (quick_mod(10, num) + quick_mod(10, num - 1)) % Mod)) % Mod) % Mod, num -= 2;
				}
			}
			else if (i > j)
			{
				int len = i - 1;
				int num = 0;
				for (int k = j - 1; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][k] * quick_mod(10, num) + b[j] * a[i][len--] * quick_mod(10, num + 1)) % Mod)) % Mod) % Mod, num += 2;
				for (int k = len; k >= 0; k--)
					ans = (ans + (((b[j] * a[i][k] * quick_mod(10, num)) % Mod)) % Mod) % Mod, num++;
			}
			else
			{
				int len = j - 1;
				int num = 0;
				for (int k = i - 1; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][len--] * quick_mod(10, num) + b[j] * a[i][k] * quick_mod(10, num + 1)) % Mod)) % Mod) % Mod, num += 2;
				for (int k = len; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][k] * quick_mod(10, num)) % Mod)) % Mod) % Mod, num++;
			}
		}
	}
	cout << ans << endl;
}


#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<list>
#include<algorithm>
#include<time.h>
#include<sstream>
using namespace std;
long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a%b); }
const long long inf = 0x7f7f7f7f;
const long long mod = 1e9 + 7;
double pi = acos(-1.0);
long long a[20][20];
string str[120000];
long long b[20];
long long Mod = 998244353;
long long quick_mod(long long a, long long b)
{
	long long ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % Mod;
		b >>= 1;
		a = (a * a) % Mod;
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> str[i];
		int len = str[i].length();
		for (int j = 0; j < str[i].length(); j++)
		{
			long long t = str[i][j] - '0';
			ans = (ans + t * (quick_mod(10, (len - j - 1) * 2 + 1) + quick_mod(10, (len - j - 1) * 2))) % Mod;
		}
		b[len]++;
		for (int j = 0; j < len; j++)
			a[len][j] += (str[i][j] - '0');
	}
	for (int i = 1; i <= 9; i++)
	{
		if (b[i] == 0)
			continue;
		for (int j = 1; j <= 9; j++)
		{
			if (b[j] == 0)
				continue;
			if (i == j)
			{
				int num = i * 2 - 1;
				for (int k = 0; k < i; k++)
				{
					long long t = a[i][k];
					ans = (ans + ((b[i] - 1)*(t * (quick_mod(10, num) + quick_mod(10, num - 1)) % Mod)) % Mod) % Mod, num -= 2;
				}
			}
			else if (i > j)
			{
				int len = i - 1;
				int num = 0;
				for (int k = j - 1; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][k] * quick_mod(10, num) % Mod + b[j] * a[i][len--] * quick_mod(10, num + 1) % Mod) % Mod)) % Mod) % Mod, num += 2;
				for (int k = len; k >= 0; k--)
					ans = (ans + (((b[j] * a[i][k] * quick_mod(10, num)) % Mod)) % Mod) % Mod, num++;
			}
			else
			{
				int len = j - 1;
				int num = 0;
				for (int k = i - 1; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][len--] * quick_mod(10, num) % Mod + b[j] * a[i][k] * quick_mod(10, num + 1) % Mod) % Mod)) % Mod) % Mod, num += 2;
				for (int k = len; k >= 0; k--)
					ans = (ans + (((b[i] * a[j][k] * quick_mod(10, num)) % Mod)) % Mod) % Mod, num++;
			}
		}
	}
	cout << ans % Mod << endl;
}


#include<bits/stdc++.h>
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
#define fo(x,y) for(int i=(x);i<=(y);++i){cout<<i<<endl;}
#define me(arr,val) memset(arr,val,sizeof arr)
#define inf 10e8
#define infl LLONG_MAX
#define mod 998244353ll
#define f first
#define s second
#define  g(t,a)  (get<a>(t))
#define pra(a) for(auto i:a){cout<<i<<endl;}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//int dx[]={+1,-1,0,0};//vertical horizontal
//int dy[]={0,0,+1,-1};//vertical horizontal
//int dx[]={+1,+1,-1,-1,+2,-2,+2,-2};//knights move
//int dy[]={+2,-2,+2,-2,+1,+1,-1,-1};//knights move
//int dx[]={+1,-1,0,0,+1,+1,-1,-1};//vertical horizontal diagonal
//int dy[]={0,0,+1,-1,-1,+1,+1,-1};//vertical horizontal diagonal
using namespace std;
using namespace __gnu_pbds;
/*typedef tree<int, null_type,less<int>, rb_tree_tag,
             tree_order_statistics_node_update>indexed_set;
for set use above*/
typedef tree<pair<int,int>, null_type,less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> indexed_multiset;

ll num_of_digit[12],dig_pos_f[12][12],digit_sum[25];

void cnt(ll num)
{
    ll dig_cnt=0;
    for(ll i=1;num;++dig_cnt,++i)
    {
        ++dig_pos_f[num%10][i];
        num/=10;
    }
    ++num_of_digit[dig_cnt];
}

int main()
{
    ll n,ans=0;
    cin>>n;
    while(n--)
    {
        ll num;
        cin>>num;
        cnt(num);
    }
    for(ll pos=1;pos<=10;++pos)
    {
        ll i,j,side;
        for(i=pos-1,j=1;i>=pos/2+1;--i,++j)
        {
            if(i==pos/2+1&&pos%2)
            {
                side=1;
            }
            else
            {
                side=2;
            }
            for(ll digit=0;digit<=9;++digit)
            {
                digit_sum[pos]+=dig_pos_f[digit][i]*num_of_digit[j]*side*digit;
            }
        }
        for(i=(pos+1)/2,j=pos-i;j<=10;++j)
        {
            for(ll digit=0;digit<=9;++digit)
            {
                digit_sum[pos]+=dig_pos_f[digit][i]*num_of_digit[j]*digit;
            }
        }
    }
    for(ll i=1,carry=0,pow10=1;i<=22;++i,pow10=(pow10*10)%mod)
    {
        ans=(ans+((digit_sum[i]+carry)%10*pow10)%mod)%mod;
        carry=(digit_sum[i]+carry)/10;
    }
    printf("%lld",ans);
    return 0;
}


#include<bits/stdc++.h>
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
#define fo(a,x,y) for(int i=(x);i<=(y);++i){cout<<a[i]<<" ";}cout<<endl;
#define me(arr,val) memset(arr,val,sizeof arr)
#define inf 10e8
#define infl LLONG_MAX
#define mod 998244353ll
#define f first
#define s second
#define  g(t,a)  (get<a>(t))
#define pra(a) for(auto i:a){cout<<i<<endl;}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//int dx[]={+1,-1,0,0};//vertical horizontal
//int dy[]={0,0,+1,-1};//vertical horizontal
//int dx[]={+1,+1,-1,-1,+2,-2,+2,-2};//knights move
//int dy[]={+2,-2,+2,-2,+1,+1,-1,-1};//knights move
//int dx[]={+1,-1,0,0,+1,+1,-1,-1};//vertical horizontal diagonal
//int dy[]={0,0,+1,-1,-1,+1,+1,-1};//vertical horizontal diagonal
using namespace std;
using namespace __gnu_pbds;
/*typedef tree<int, null_type,less<int>, rb_tree_tag,
             tree_order_statistics_node_update>indexed_set;
for set use above*/
typedef tree<pair<int,int>, null_type,less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> indexed_multiset;

ll num_of_digit[45],dig_pos_f[45][45],digit_sum[45];

void cnt(ll num)
{
    ll dig_cnt=0;
    for(ll i=1;num;++dig_cnt,++i)
    {
        ++dig_pos_f[num%10][i];
        num/=10;
    }
    ++num_of_digit[dig_cnt];
}

int main()
{
    ll n,ans=0;
    cin>>n;
    while(n--)
    {
        ll num;
        cin>>num;
        cnt(num);
    }
    for(ll pos=1;pos<=20;++pos)
    {
        ll i,j,side;
        for(i=pos-1,j=1;i>=pos/2+1;--i,++j)
        {
            if(i==pos/2+1&&pos%2)
            {
                side=1;
            }
            else
            {
                side=2;
            }
            for(ll digit=0;digit<=9;++digit)
            {
                digit_sum[pos]+=(dig_pos_f[digit][i]*num_of_digit[j]*side*digit)%mod;
                digit_sum[pos]%=mod;
            }
        }
        for(i=(pos+1)/2,j=pos-i;j<=10;++j)
        {
            for(ll digit=0;digit<=9;++digit)
            {
                digit_sum[pos]+=(dig_pos_f[digit][i]*num_of_digit[j]*digit)%mod;
                digit_sum[pos]%=mod;
            }
        }
    }
    for(ll i=1,carry=0,pow10=1;i<=40;++i,pow10=(pow10*10)%mod)
    {
        ans=(ans+(((digit_sum[i]+carry)%10)*pow10)%mod)%mod;
        carry=(digit_sum[i]+carry)/10;
    }
    printf("%lld",ans);
    return 0;
}


#include<bits/stdc++.h>
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
#define fo(a,x,y) for(int i=(x);i<=(y);++i){cout<<a[i]<<" ";}cout<<endl;
#define me(arr,val) memset(arr,val,sizeof arr)
#define inf 10e8
#define infl LLONG_MAX
#define mod 1000000007
#define f first
#define s second
#define  g(t,a)  (get<a>(t))
#define pra(a) for(auto i:a){cout<<i<<endl;}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//int dx[]={+1,-1,0,0};//vertical horizontal
//int dy[]={0,0,+1,-1};//vertical horizontal
//int dx[]={+1,+1,-1,-1,+2,-2,+2,-2};//knights move
//int dy[]={+2,-2,+2,-2,+1,+1,-1,-1};//knights move
//int dx[]={+1,-1,0,0,+1,+1,-1,-1};//vertical horizontal diagonal
//int dy[]={0,0,+1,-1,-1,+1,+1,-1};//vertical horizontal diagonal
using namespace std;
using namespace __gnu_pbds;
/*typedef tree<int, null_type,less<int>, rb_tree_tag,
             tree_order_statistics_node_update>indexed_set;
for set use above*/
typedef tree<pair<int,int>, null_type,less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> indexed_multiset;

ll num_of_digit[12];

ll cnt_digit(ll num)
{
    ll cnt=0;
    while(num)
    {
        ++cnt;
        num/=10;
    }
    return cnt;
}

vector<ll>find_digits(ll num)
{
    vector<ll>v;
    while(num)
    {
        v.push_back(num%10);
        num/=10;
    }
    return v;
}

ll contri_odd(vector<ll>&digits,ll len)
{
    ll pow10=1,res=0;
    for(ll i=0;i<digits.size();++i)
    {
        res=(res+(digits[i]*pow10)%mod)%mod;
        pow10=(pow10*10)%mod;
        if(i+1<=len)
        {
            pow10=(pow10*10)%mod;
        }
    }
    return res;
}

ll contri_even(vector<ll>&digits,ll len)
{
    ll pow10=1,res=0;
    for(ll i=0;i<digits.size();++i)
    {
        if(i+1<=len)
        {
            pow10=(pow10*10)%mod;
        }
        res=(res+(digits[i]*pow10)%mod)%mod;
        pow10=(pow10*10)%mod;
    }
    return res;
}

int main()
{
    ll n,ans=0;
    cin>>n;
    ll a[n+5];
    for(ll i=1;i<=n;++i)
    {
        cin>>a[i];
        ++num_of_digit[cnt_digit(a[i])];
    }
    for(ll i=1;i<=n;++i)
    {
        vector<ll>digits=find_digits(a[i]);
        for(ll len=1;len<=10;++len)
        {
            ans=(ans+(num_of_digit[len]*contri_odd(digits,len))%mod)%mod;
            ans=(ans+(num_of_digit[len]*contri_even(digits,len))%mod)%mod;
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
#define fo(a,x,y) for(int i=(x);i<=(y);++i){cout<<a[i]<<" ";}cout<<endl;
#define me(arr,val) memset(arr,val,sizeof arr)
#define inf 10e8
#define infl LLONG_MAX
#define mod 998244353ll
#define f first
#define s second
#define  g(t,a)  (get<a>(t))
#define pra(a) for(auto i:a){cout<<i<<endl;}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//int dx[]={+1,-1,0,0};//vertical horizontal
//int dy[]={0,0,+1,-1};//vertical horizontal
//int dx[]={+1,+1,-1,-1,+2,-2,+2,-2};//knights move
//int dy[]={+2,-2,+2,-2,+1,+1,-1,-1};//knights move
//int dx[]={+1,-1,0,0,+1,+1,-1,-1};//vertical horizontal diagonal
//int dy[]={0,0,+1,-1,-1,+1,+1,-1};//vertical horizontal diagonal
using namespace std;
using namespace __gnu_pbds;
/*typedef tree<int, null_type,less<int>, rb_tree_tag,
             tree_order_statistics_node_update>indexed_set;
for set use above*/
typedef tree<pair<int,int>, null_type,less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> indexed_multiset;

ll num_of_digit[12];

ll cnt_digit(ll num)
{
    ll cnt=0;
    while(num)
    {
        ++cnt;
        num/=10;
    }
    return cnt;
}

vector<ll>find_digits(ll num)
{
    vector<ll>v;
    while(num)
    {
        v.push_back(num%10);
        num/=10;
    }
    return v;
}

ll contri_odd(vector<ll>&digits,ll len)
{
    ll pow10=1,res=0;
    for(ll i=0;i<digits.size();++i)
    {
        res=(res+(digits[i]*pow10)%mod)%mod;
        pow10=(pow10*10)%mod;
        if(i+1<=len)
        {
            pow10=(pow10*10)%mod;
        }
    }
    return res;
}

ll contri_even(vector<ll>&digits,ll len)
{
    ll pow10=1,res=0;
    for(ll i=0;i<digits.size();++i)
    {
        if(i+1<=len)
        {
            pow10=(pow10*10)%mod;
        }
        res=(res+(digits[i]*pow10)%mod)%mod;
        pow10=(pow10*10)%mod;
    }
    return res;
}

int main()
{
    ll n,ans=0;
    cin>>n;
    ll a[n+5];
    for(ll i=1;i<=n;++i)
    {
        cin>>a[i];
        ++num_of_digit[cnt_digit(a[i])];
    }
    for(ll i=1;i<=n;++i)
    {
        vector<ll>digits=find_digits(a[i]);
        for(ll len=1;len<=10;++len)
        {
            ans=(ans+(num_of_digit[len]*contri_odd(digits,len))%mod)%mod;
            ans=(ans+(num_of_digit[len]*contri_even(digits,len))%mod)%mod;
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
#define fo(a,x,y) for(int i=(x);i<=(y);++i){cout<<a[i]<<" ";}cout<<endl;
#define me(arr,val) memset(arr,val,sizeof arr)
#define inf 10e8
#define infl LLONG_MAX
#define mod 998244353ll
#define f first
#define s second
#define  g(t,a)  (get<a>(t))
#define pra(a) for(auto i:a){cout<<i<<endl;}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//int dx[]={+1,-1,0,0};//vertical horizontal
//int dy[]={0,0,+1,-1};//vertical horizontal
//int dx[]={+1,+1,-1,-1,+2,-2,+2,-2};//knights move
//int dy[]={+2,-2,+2,-2,+1,+1,-1,-1};//knights move
//int dx[]={+1,-1,0,0,+1,+1,-1,-1};//vertical horizontal diagonal
//int dy[]={0,0,+1,-1,-1,+1,+1,-1};//vertical horizontal diagonal
using namespace std;
using namespace __gnu_pbds;
/*typedef tree<int, null_type,less<int>, rb_tree_tag,
             tree_order_statistics_node_update>indexed_set;
for set use above*/
typedef tree<pair<int,int>, null_type,less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> indexed_multiset;

ll num_of_digit[12],dig_pos_f[12][12],digit_sum[30],a[30];

void cnt(ll num)
{
    ll dig_cnt=0;
    for(ll i=1;num;++dig_cnt,++i)
    {
        ++dig_pos_f[num%10][i];
        num/=10;
    }
    ++num_of_digit[dig_cnt];
}

int main()
{
    ll n,ans=0;
    cin>>n;
    while(n--)
    {
        ll num;
        cin>>num;
        cnt(num);
    }
    for(ll pos=1;pos<=10;++pos)
    {
        ll i,j,side;
        for(i=pos-1,j=1;i>=pos/2+1;--i,++j)
        {
            if(i==pos/2+1&&pos%2)
            {
                side=1;
            }
            else
            {
                side=2;
            }
            for(ll digit=0;digit<=9;++digit)
            {
                digit_sum[pos]+=(dig_pos_f[digit][i]*num_of_digit[j]*side*digit)%mod;
                digit_sum[pos]%=mod;
            }
        }
        for(i=(pos+1)/2,j=pos-i;j<=10;++j)
        {
            for(ll digit=0;digit<=9;++digit)
            {
                digit_sum[pos]+=(dig_pos_f[digit][i]*num_of_digit[j]*digit)%mod;
                digit_sum[pos]%=mod;
            }
        }
    }
    for(ll i=1,carry=0,pow10=1;i<=25;++i,pow10=(pow10*10)%mod)
    {
        ans=(ans+(((digit_sum[i]+carry)%10)*pow10)%mod)%mod;
        carry=(digit_sum[i]+carry)/10;
    }
    printf("%lld",ans);
    return 0;
}


#include<bits/stdc++.h>
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
#define fo(a,x,y) for(int i=(x);i<=(y);++i){cout<<a[i]<<" ";}cout<<endl;
#define me(arr,val) memset(arr,val,sizeof arr)
#define inf 10e8
#define infl LLONG_MAX
#define mod 998244353ll
#define f first
#define s second
#define  g(t,a)  (get<a>(t))
#define pra(a) for(auto i:a){cout<<i<<endl;}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//int dx[]={+1,-1,0,0};//vertical horizontal
//int dy[]={0,0,+1,-1};//vertical horizontal
//int dx[]={+1,+1,-1,-1,+2,-2,+2,-2};//knights move
//int dy[]={+2,-2,+2,-2,+1,+1,-1,-1};//knights move
//int dx[]={+1,-1,0,0,+1,+1,-1,-1};//vertical horizontal diagonal
//int dy[]={0,0,+1,-1,-1,+1,+1,-1};//vertical horizontal diagonal
using namespace std;
using namespace __gnu_pbds;
/*typedef tree<int, null_type,less<int>, rb_tree_tag,
             tree_order_statistics_node_update>indexed_set;
for set use above*/
typedef tree<pair<int,int>, null_type,less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> indexed_multiset;

ll num_of_digit[12],dig_pos_f[12][12],digit_sum[30],a[30];

void cnt(ll num)
{
    ll dig_cnt=0;
    for(ll i=1;num;++dig_cnt,++i)
    {
        ++dig_pos_f[num%10][i];
        num/=10;
    }
    ++num_of_digit[dig_cnt];
}

int main()
{
    ll n,ans=0;
    cin>>n;
    while(n--)
    {
        ll num;
        cin>>num;
        cnt(num);
    }
    /*fo(num_of_digit,0,9);
    for(ll i=0;i<=9;++i)
    {
        for(ll j=1;j<=10;++j)
        {
            printf("%lld ",dig_pos_f[i][j]);
        }
        cout<<endl;
    }*/
    for(ll pos=1;pos<=10;++pos)
    {
        ll i,j,side;
        //pr(pos);
        for(i=pos-1,j=1;i>=pos/2+1;--i,++j)
        {
            //pr(i);
            //pr(j);
            if(i==pos/2+1&&pos%2)
            {
                side=1;
            }
            else
            {
                side=2;
            }
            for(ll digit=0;digit<=9;++digit)
            {
                //if(digit==0||digit==6)
                //{
                digit_sum[pos]+=dig_pos_f[digit][i]*num_of_digit[j]*side*digit;
                //pr(digit_sum[pos]);
                //pr(side);
                //pr(digit);
                //}
            }
        }
        for(i=(pos+1)/2,j=pos-i;j<=10;++j)
        {
            //pr(i);
            //pr(j);
            for(ll digit=0;digit<=9;++digit)
            {
                //if(digit==0||digit==6)
                //{
                digit_sum[pos]+=dig_pos_f[digit][i]*num_of_digit[j]*digit;
                //pr(digit_sum[pos]);
                //pr(digit);
                //}
            }
        }
    }
    for(ll i=1,carry=0,pow10=1;i<=25;++i,pow10=(pow10*10)%mod)
    {
        ans=(ans+((digit_sum[i]+carry)%10*pow10)%mod)%mod;
        //pr(digit_sum[i]);
        //pr(carry);
        carry=((digit_sum[i]+carry)%mod)/10;
        //pr(carry);
        //pr(ans);
    }
    printf("%lld",ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
// #define ull long long
#define ull unsigned long long int
#define debug(x) cout<<#x<<'='<<(x)<<endl<<flush
#define N (ull)1.5e9+99
#define pb push_back
#define mod 998244353
// #define mod 1000000007
#define f(i,n) for(ull i=0;i<n;i++)
#define fab(i,a,b) for(ull i=a;i<=b;i++)
#define input(arr,n) f(_,n) cin>>arr[_]
#define out(arr,n) f(_,n) cout<<arr[_]<<" ";cout<<endl;
#define pi 3.141592653589793238
bool sortcol( vector<ull>& v1, vector<ull>& v2 ) { return v1[0] < v2[0]; }
ull l[10]={0};
ull stoint(string s)
{
    ull p=1;ull ans=0;
    ull n=s.size();
    for(int i=n-1;i>=0;i--)
    {
        // debug(i);
        ans+=p*(s[i]-'0');p*=10;p%=mod;
        ans%=mod;
    }
    return ans;
}
ull func(string a)
{
    string arr[10],brr[10];
    for(ull i=1;i<=9;i++)
    {
        if(i>a.size())
        {
            arr[i]=arr[i-1];brr[i]=brr[i-1];continue;
        }
        string aa="";
        aa+=a.substr(0,a.size()-i);
        string ss=aa,jj=aa;
        for(ull ii=a.size()-i;ii<a.size();ii++)
        {
            ss+='0';ss+=a[ii];jj+=a[ii];jj+='0';
        }
        arr[i]=ss; brr[i]=jj;
        // debug(ss);debug(jj);debug(stoint(jj));
    }
    // return 0;
    ull ans=0;
    // debug(ans);
    for(ull i=1;i<=9;i++)
    {
        // debug(i);
        ull aa=stoint(arr[i]);
        // debug(aa);
        aa%=mod;
        // debug(aa);
        aa*=l[i];aa%=mod;
        ull bb=stoint(brr[i]); bb%=mod;
        bb*=l[i]; bb%=mod;
        ans+=aa+bb;
        ans%=mod;
        // debug(i);

    }
    ans+=mod; ans%=mod;
    return ans;
}
void solve()
{
    ull n; cin>>n;
    // debug(n);
    string arr[n];
    f(i,n)
    {
        string a; cin>>a;arr[i]=a;
        l[a.size()]++;
    }
    ull ans=0;
    // debug(ans);
    f(i,n)
    {
        ans+=func(arr[i]);
        ans%=mod;
        // debug(ans);
    }
    ans+=mod; ans%=mod;
    cout<<ans<<endl;return;
}

main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    // ull t; cin>>t; while(t--)
    solve();
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
// #define ull long long
#define ull unsigned long long int
#define debug(x) cout<<#x<<'='<<(x)<<endl<<flush
#define N (ull)1.5e9+99
#define pb push_back
#define mod 998244353
// #define mod 1000000007
#define f(i,n) for(ull i=0;i<n;i++)
#define fab(i,a,b) for(ull i=a;i<=b;i++)
#define input(arr,n) f(_,n) cin>>arr[_]
#define out(arr,n) f(_,n) cout<<arr[_]<<" ";cout<<endl;
#define pi 3.141592653589793238
bool sortcol( vector<ull>& v1, vector<ull>& v2 ) { return v1[0] < v2[0]; }
ull l[10]={0};
ull stoint(string s)
{
    ull p=1;ull ans=0;
    ull n=s.size();
    for(int i=n-1;i>=0;i--)
    {
        // debug(i);
        ans+=p*(s[i]-'0');p*=10;
    }
    return ans;
}
ull func(string a)
{
    string arr[10],brr[10];
    for(ull i=1;i<=9;i++)
    {
        if(i>a.size())
        {
            arr[i]=arr[i-1];brr[i]=brr[i-1];continue;
        }
        string aa="";
        aa+=a.substr(0,a.size()-i);
        string ss=aa,jj=aa;
        for(ull ii=a.size()-i;ii<a.size();ii++)
        {
            ss+='0';ss+=a[ii];jj+=a[ii];jj+='0';
        }
        arr[i]=ss; brr[i]=jj;
        // debug(ss);debug(jj);debug(stoint(jj));
    }
    // return 0;
    ull ans=0;
    // debug(ans);
    for(ull i=1;i<=9;i++)
    {
        // debug(i);
        ull aa=stoint(arr[i]);
        // debug(aa);
        aa%=mod;
        // debug(aa);
        aa*=l[i];aa%=mod;
        ull bb=stoint(brr[i]); bb%=mod;
        bb*=l[i]; bb%=mod;
        ans+=aa+bb;
        ans%=mod;
        // debug(i);

    }
    ans+=mod; ans%=mod;
    return ans;
}
void solve()
{
    ull n; cin>>n;
    // debug(n);
    string arr[n];
    f(i,n)
    {
        string a; cin>>a;arr[i]=a;
        l[a.size()]++;
    }
    ull ans=0;
    // debug(ans);
    f(i,n)
    {
        ans+=func(arr[i]);
        ans%=mod;
        // debug(ans);
    }
    ans+=mod; ans%=mod;
    cout<<ans<<endl;return;
}

main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    // ull t; cin>>t; while(t--)
    solve();
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define debug(x) cout<<#x<<'='<<(x)<<endl<<flush
#define N (int)1.5e9+99
#define pb push_back
#define mod 998244353
// #define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<=b;i++)
#define input(arr,n) f(_,n) cin>>arr[_]
#define out(arr,n) f(_,n) cout<<arr[_]<<" ";cout<<endl;
#define pi 3.141592653589793238
bool sortcol( vector<int>& v1, vector<int>& v2 ) { return v1[0] < v2[0]; }
int l[10]={0};
int stoint(string s)
{
    int p=1;int ans=0;
    int n=s.size();
    for(int i=n-1;i>=0;i--)
    {
        ans+=p*(s[i]-'0');p*=10;
    }
    return ans;
}
int func(string a)
{
    string arr[10],brr[10];
    for(int i=1;i<=9;i++)
    {
        if(i>a.size())
        {
            arr[i]=arr[i-1];brr[i]=brr[i-1];continue;
        }
        string aa="";
        aa+=a.substr(0,a.size()-i);
        string ss=aa,jj=aa;
        for(int ii=a.size()-i;ii<a.size();ii++)
        {
            ss+='0';ss+=a[ii];jj+=a[ii];jj+='0';
        }
        arr[i]=ss; brr[i]=jj;
        // debug(ss);debug(jj);debug(stoint(jj));
    }
    // return 0;
    int ans=0;
    for(int i=1;i<=9;i++)
    {
        int aa=stoint(arr[i]);aa%=mod;
        aa*=l[i];aa%=mod;
        int bb=stoint(brr[i]); bb%=mod;
        bb*=l[i]; bb%=mod;
        ans+=aa+bb;
        ans%=mod;

    }
    return ans;
}
void solve()
{
    int n; cin>>n;
    string arr[n];
    f(i,n)
    {
        string a; cin>>a;arr[i]=a;
        l[a.size()]++;
    }
    int ans=0;
    f(i,n)
    {
        ans+=func(arr[i]);
        ans%=mod;
    }
    cout<<ans<<endl;return;
}

main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    // int t; cin>>t; while(t--)
    solve();
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
// #define ull long long
#define ull unsigned long long int
#define debug(x) cout<<#x<<'='<<(x)<<endl<<flush
#define N (ull)1.5e9+99
#define pb push_back
#define mod 998244353
// #define mod 1000000007
#define f(i,n) for(ull i=0;i<n;i++)
#define fab(i,a,b) for(ull i=a;i<=b;i++)
#define input(arr,n) f(_,n) cin>>arr[_]
#define out(arr,n) f(_,n) cout<<arr[_]<<" ";cout<<endl;
#define pi 3.141592653589793238
bool sortcol( vector<ull>& v1, vector<ull>& v2 ) { return v1[0] < v2[0]; }
ull l[13]={0};
ull stoint(string s)
{
    ull p=1;ull ans=0;
    ull n=s.size();
    for(int i=n-1;i>=0;i--)
    {
        // debug(i);
        ans+=p*(s[i]-'0');p*=10;p%=mod;
        ans%=mod;
    }
    return ans;
}
ull func(string a)
{
    string arr[11],brr[11];
    for(ull i=1;i<=10;i++)
    {
        if(i>a.size())
        {
            arr[i]=arr[i-1];brr[i]=brr[i-1];continue;
        }
        string aa="";
        aa+=a.substr(0,a.size()-i);
        string ss=aa,jj=aa;
        for(ull ii=a.size()-i;ii<a.size();ii++)
        {
            ss+='0';ss+=a[ii];jj+=a[ii];jj+='0';
        }
        arr[i]=ss; brr[i]=jj;
        // debug(ss);debug(jj);debug(stoint(jj));
    }
    // return 0;
    ull ans=0;
    // debug(ans);
    for(ull i=1;i<=10;i++)
    {
        // debug(i);
        ull aa=stoint(arr[i]);
        // debug(aa);
        aa%=mod;
        // debug(aa);
        aa*=l[i];aa%=mod;
        ull bb=stoint(brr[i]); bb%=mod;
        bb*=l[i]; bb%=mod;
        ans+=aa+bb;
        ans%=mod;
        // debug(i);

    }
    ans+=mod; ans%=mod;
    return ans;
}
void solve()
{
    ull n; cin>>n;
    // debug(n);
    string arr[n];
    f(i,n)
    {
        string a; cin>>a;arr[i]=a;
        l[a.size()]++;
    }
    ull ans=0;
    // debug(ans);
    f(i,n)
    {
        ans+=func(arr[i]);
        ans%=mod;
        // debug(ans);
    }
    ans+=mod; ans%=mod;
    cout<<ans<<endl;return;
}

main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    // ull t; cin>>t; while(t--)
    solve();
}


#include<bits/stdc++.h>
using namespace std;
int n;
string temp[100001];
long long mod=998244353;
long long ans=0;
long long s[20]={0};
long long c[25];
int main(){
cin>>n;
c[0]=1;
for(int i=1;i<=20;i++){
	c[i]=(c[i-1]*10)%mod;
}
for(int i=1;i<=n;i++){
	cin>>temp[i];

	int sum=temp[i].size()-1;
	s[sum+1]++;
	long long a=1;
while(sum>=0){
	ans+=((((temp[i][sum]-48)*(a+a*10))%mod)*n)%mod;
	ans%=mod;
	a=(a*100)%mod;
	sum--;

}}

for(int i=1;i<=n;i++){
	int sum=0;
	for(int j=temp[i].size()-2;j>0;j--){
		sum++;
		if(s[j]){

		int p=sum;
		while(p>0){
			int l=2*(temp[i].size())-1-2*(sum-p);
			long long q=(c[l-1]-c[l-p-1]+mod)%mod;
			ans=(ans-(((((temp[i][sum-p]-48)*q)%mod)*s[j])%mod)+mod)%mod;
			p--;
		}
	}

	}
	sum=0;
		for(int j=temp[i].size()-1;j>0;j--){
		sum++;
		if(s[j]){

		int p=sum;
		while(p>0){
			int l=2*(temp[i].size())-2*(sum-p);
			long long q=(c[l-1]-c[l-p-1]+mod)%mod;

			ans=(ans-(((((temp[i][sum-p]-48)*q)%mod)*s[j])%mod)+mod)%mod;
			p--;
		}

	}
	}

}

cout<<ans;
return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define LL long long
#define mod 998244353
#define MAXN 100005
LL n;
LL a[MAXN];
LL tot[MAXN];
LL wei[MAXN];
LL result;
int main() {
	scanf ( "%lld", &n );
	for ( int i = 1;i <= n;i ++ ) {
		scanf ( "%lld", &a[i] );
		LL tmp = a[i];
		int cnt = 0;
		while ( tmp ) {
			cnt ++;
			tmp /= 10;
		}
		wei[i] = cnt;
		tot[cnt] ++;
	}
	for ( int i = 1;i <= n;i ++ ) {
	//	printf ( "%d:\n", i );
		for ( int j = 1;j < wei[i];j ++ ) {
			if ( tot[j] == 0 ) continue;
			LL x = a[i], cs = 1, many = 1;
			while ( x ) {
				if ( many <= j )
					result = ( result + ( ( x % 10 ) * cs % mod + cs * 10 % mod * ( x % 10 ) % mod ) % mod * tot[j] % mod ) % mod;
				else
					result = ( result + tot[j] * 2 % mod * ( x % 10 ) % mod * cs % mod ) % mod;
				x /= 10;
				if ( many <= j ) cs *= 100;
				else cs *= 10;
				many ++;
			//	printf ( "%d %d %d-----[%d]\n", x, cs, many, result );
			}
		}
		for ( int j = wei[i];j <= 10;j ++ ) {
			if ( tot[j] == 0 ) continue;
			LL x = a[i], cs = 1;
			while ( x ) {
				result = ( result + ( ( x % 10 ) * cs % mod + cs * 10 % mod * ( x % 10 ) % mod ) % mod * tot[j] % mod ) % mod;
				//if ( wei[i] == j )
				//	result = ( result - ( ( x % 10 ) * cs % mod + cs * 10 % mod * ( x % 10 ) % mod + mod ) % mod ) % mod;
				x /= 10;
				cs *= 100;
		//		printf ( "%d %d___________-----[%d]\n", x, cs, result );
			}
		}
	}
	printf ( "%lld", result );
	return 0;
}


// luogu-judger-enable-o2
#include <cstdio>
#include <algorithm>
using namespace std;

#define N 100005
#define ll long long
#define mod 998244353

int sum[20];
ll fac[20];

int fun(int x){
	int res=0;
	while(x){
		(sum[res]+=x%10)%=mod;
		x/=10;
		++res;
	}
	return res;
}

int n;

ll ans;
int a[N];

void init(){
	fac[0]=1;
	for(int i=1;i<=20;++i) fac[i]=fac[i-1]*10%mod;
}

int main(){
	init();
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",a+i);
		a[i]=fun(a[i]);
	}
	for(int i=0;i<10;++i){
		for(int j=1;j<=n;++j){
			if(i<=(a[j]-1))   (ans+=1LL*fac[2*i]*11LL%mod*sum[i]%mod)%=mod;
			else              (ans+=2LL*fac[a[j]+i]%mod*sum[i]%mod)%=mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include <cstdio>
#include <iostream>
#define MAXW 15
#define MAXN 100005
#define Mod 998244353
#define Int register int
using namespace std;
typedef long long LL;
int cnt[MAXN];
LL a[MAXN], zh[MAXW];
inline void read(LL &x)
{
	x = 0;
	LL f = 1;
	char s = getchar();
	while (s < '0' ||s > '9')
	{
		if (s == '-')
			f = -1;
		s = getchar();
	}
	while (s >= '0' && s <= '9')
	{
		x = (x << 3) + (x << 1) + (s ^ 48);
		s = getchar();
	}
	x *= f;
}
void count(LL x)
{
    int tot = 0;
    while ( x )
    {
        tot ++;
        x /= 10;
    }
    cnt[tot] ++;
}
int main()
{
	LL n;
	read( n );
    zh[1] = 1;
    for (Int i = 2; i < 10; ++ i)
		zh[i] = (zh[i - 1] * 10) % Mod;
    for (Int i = 1; i <= n; ++ i)
    {
        read( a[i] );
        count( a[i] );
    }
    LL Ans = 0;
    for (Int i = 1; i <= n; ++ i)
    {
        LL t = a[i];
		int Index = 0;
        while( t )
        {
            LL num = t % 10;
            t /= 10;
            ++ Index;
            for (Int j = 1; j <= 10; ++ j)
            {
                if (j >= Index)
                {
                    Ans += num * cnt[j] * zh[Index * 2];
                    Ans += num * cnt[j] * zh[Index * 2 - 1];
                }
                else Ans += 2 * num * cnt[j] * zh[Index + j];
            }
            Ans %= Mod;
        }
    }
    printf("%lld", Ans);
	return 0;
}


#include<iostream>
using namespace std;
typedef long long LL;
LL read(){
	#define cg (c=getchar())
	LL x,f=1;char c;
	while(cg<'0'||'9'<c)if(c=='-')f=-1;
	for(x=(c^48);'0'<=cg&&c<='9';x=(x<<3)+(x<<1)+(c^48));
	return x*f;
	#undef cg
}
#define MAXL 20
const LL MOD=998244353;
LL N,powTen[MAXL+5],ans;
LL tot[MAXL+5],bas[MAXL+5];
string s;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>N;
	powTen[0]=1;
	for(LL i=1;i<=20;++i)powTen[i]=((powTen[i-1]<<3)%MOD+(powTen[i-1]<<1)%MOD)%MOD;
	for(LL i=1;i<=N;++i){
		cin>>s;
		++tot[s.length()];
		for(LL j=s.length()-1;j>=0;--j)(bas[s.length()-1-j]+=(s[j]^48))%=MOD;
	}
	for(LL i=0;i<=9;++i)for(LL j=1;j<=10;++j){
		(ans+=bas[i]*tot[j]%MOD*powTen[min(i<<1,i+j)])%=MOD;
		(ans+=bas[i]*tot[j]%MOD*powTen[min(i<<1|1,i+j)])%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


#include<map>
#include<list>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define il inline
#define ll long long
#define rl register ll
#define ri register int
#define rc register char
using namespace std;
il int read(){
	rc c=' ';
	ri v=0,x=1;
	while((c<'0')||(c>'9')){if(c=='-') x=-1;c=getchar();}
	while((c>='0')&&(c<='9')){v=(v<<1)+(v<<3)+(c^48);c=getchar();}
	return v*x;
}
il void write(ri x){
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10^48);
}
const int N=1e5+10,mod=998244353;
int n,x,y,a[N],b[N],c[N][10],t[N],pw[20]={1,1},ans;
int main(){
	n=read();
	for(ri i=2;i<=20;i++)
		pw[i]=1ll*pw[i-1]*10%mod;
	for(ri i=1;i<=n;i++){
		a[i]=x=read();
		while(x) c[i][++b[i]]=x%10,x/=10;
		t[b[i]]++;
	}
	for(ri i=1;i<=n;i++){
		for(ri j=b[i];j<=10;j++)
			for(ri k=1;k<=b[i];k++)
				ans=(ans+11ll*t[j]*c[i][k]*pw[2*k-1])%mod;
		for(ri j=1;j<=b[i]-1;j++){
			ri tmp=0;
			for(ri k=1;k<=j;k++)
				tmp=(tmp+11ll*c[i][k]*pw[2*k-1])%mod;
			for(ri k=j+1;k<=b[i];k++)
				tmp=(tmp+2ll*c[i][k]*pw[k+j])%mod;
			ans=(ans+1ll*tmp*t[j])%mod;
		}
	}
	write(ans);
	return ~~(0-0);
}


#include "bits/stdc++.h"

using namespace std;
const int mod = 998244353;

int get_di(long long x) {
    long long ans = 0;
    while (x) {
        ans++;
        x /= 10;
    }
    return ans;
}

long long a[100004][14];
int cnt[14];

int main() {
    long long n;
    cin >> n;
    long long x;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &x);
        int d = get_di(x);
        a[cnt[d]++][d] = x;
    }
    long long ans = 0;
    for (int i = 1; i <= 10; ++i) {
        for (int j = 1; j <= 10; ++j) {
            for (int k = 0; k < cnt[i]; ++k) {
                long long base = 1;
                long long temp = a[k][i];
                long long y = j;
                long long sum = 0;
                while (temp) {
                    sum += base * (temp % 10) % mod;
                    sum %= mod;
                    if (y > 0)base *= 100;
                    else base *= 10;
                    base %= mod;
                    temp /= 10;
                    y--;
                }
                base = 10;
                temp = a[k][i];
                y = j - 1;
                while (temp) {
                    sum += base * (temp % 10) % mod;
                    sum %= mod;
                    if (y > 0)base *= 100;
                    else base *= 10;
                    base %= mod;
                    temp /= 10;
                    y--;
                }
                sum *= cnt[j];
                sum %= mod;
                ans += sum;
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
}


// luogu-judger-enable-o2
#include <cstdio>
#include <algorithm>
using namespace std;

#define N 100005
#define ll long long
#define mod 998244353

ll sum[20];
ll fac[20];

ll fun(ll x){
	ll res=0;
	while(x){
		(sum[res]+=x%10)%=mod;
		x/=10;
		++res;
	}
	return res;
}

int n;

ll ans;
ll a[N];

void init(){
	fac[0]=1;
	for(int i=1;i<=20;++i) fac[i]=fac[i-1]*10%mod;
}

int main(){
	init();
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%lld",a+i);
		a[i]=fun(a[i]);
	}
	for(int i=0;i<10;++i){
		for(int j=1;j<=n;++j){
			if(i<=(a[j]-1))   (ans+=1LL*fac[2*i]*11LL%mod*sum[i]%mod)%=mod;
			else              (ans+=2LL*fac[a[j]+i]%mod*sum[i]%mod)%=mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define LL unsigned long long
#define mod 998244353
#define MAXN 100005
LL n;
LL a[MAXN];
LL tot[MAXN];
LL wei[MAXN];
LL result;
int main() {
	scanf ( "%lld", &n );
	for ( int i = 1;i <= n;i ++ ) {
		scanf ( "%lld", &a[i] );
		LL tmp = a[i];
		int cnt = 0;
		while ( tmp ) {
			cnt ++;
			tmp /= 10;
		}
		wei[i] = cnt;
		tot[cnt] ++;
	}
	for ( int i = 1;i <= n;i ++ ) {
	//	printf ( "%d:\n", i );
		for ( int j = 1;j < wei[i];j ++ ) {
			if ( tot[j] == 0 ) continue;
			LL x = a[i], cs = 1, many = 1;
			while ( x ) {
				if ( many <= j )
					result = ( result + ( ( x % 10 ) * cs % mod + cs * 10 % mod * ( x % 10 ) % mod ) % mod * tot[j] % mod ) % mod;
				else
					result = ( result + tot[j] * 2 % mod * ( x % 10 ) % mod * cs % mod ) % mod;
				x /= 10;
				if ( many <= j ) cs *= 100;
				else cs *= 10;
				many ++;
			//	printf ( "%d %d %d-----[%d]\n", x, cs, many, result );
			}
		}
		for ( int j = wei[i];j <= 10;j ++ ) {
			if ( tot[j] == 0 ) continue;
			LL x = a[i], cs = 1;
			while ( x ) {
				result = ( result + ( ( x % 10 ) * cs % mod + cs * 10 % mod * ( x % 10 ) % mod ) % mod * tot[j] % mod ) % mod;
				//if ( wei[i] == j )
				//	result = ( result - ( ( x % 10 ) * cs % mod + cs * 10 % mod * ( x % 10 ) % mod + mod ) % mod ) % mod;
				x /= 10;
				cs *= 100;
		//		printf ( "%d %d___________-----[%d]\n", x, cs, result );
			}
		}
	}
	printf ( "%lld", result % mod );
	return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 100001, mod = 998244353;

int a[N], l[20], p[100], aux[20], aa[20];

int len(int x) {
        int cnt = 0;
        while(x) ++cnt, x /= 10;
        return cnt;
}

int32_t main() {
        ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n; cin >> n;

        p[0] = 1;
        for(int i = 1; i < 100; i++) p[i] = (p[i - 1] * 10) % mod;

        for(int i = 1; i <= n; i++) cin >> a[i], l[len(a[i])]++;

        for(int i = 18; i > 0; i--) {
                aa[i] = l[i];
                l[i] += l[i + 1];
        }

        int sum = 0;
        for(int i = 1; i <= n; i++) {
                int lx = 0;
                while(a[i]) {
                        ++lx;
                        int kx = l[lx], d = a[i] % 10; a[i] /= 10;
                        sum = (sum + ((d * l[lx]) % mod * (11LL * p[(lx - 1) * 2]) % mod) % mod) % mod;
                        for(int j = lx - 1; j > 0; j--) {
                                sum = (sum + ((d * aa[j]) % mod * (2LL * p[lx + j - 1]) % mod) % mod) % mod;
                        }
                }
        }

        cout << sum << endl;

}


#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 100001, mod = 998244353;

int a[N], l[20], p[20], aux[20], aa[20];

int len(int x) {
        int cnt = 0;
        while(x) ++cnt, x /= 10;
        return cnt;
}

int32_t main() {
        ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n; cin >> n;

        p[0] = 1;
        for(int i = 1; i < 20; i++) p[i] = (p[i - 1] * 10) % mod;

        for(int i = 1; i <= n; i++) cin >> a[i], l[len(a[i])]++;

        for(int i = 1; i <= n; i++) aux[i] = (aux[i - 1] + l[i] * p[i]) % mod;

        for(int i = 18; i > 0; i--) {
                aa[i] = l[i];
                l[i] += l[i + 1];
        }

        int sum = 0;
        for(int i = 1; i <= n; i++) {
                int lx = 0, m = 1;
                while(a[i]) {
                        ++lx;
                        int kx = l[lx], ky = n - l[lx], d = a[i] % 10; a[i] /= 10;
                        sum += (d * kx) % mod * ((11) * p[(lx - 1) * 2]) % mod;sum %= mod;
                        for(int j = lx - 1; j > 0; j--) {
                                int tx = aa[j];
                                sum += ((d * tx) % mod * (2LL * p[lx - 1 + j]) % mod) % mod;sum %= mod;
                        }
                        sum %= mod;
                }
        }

        cout << sum << endl;

}


#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 100001, mod = 998244353;

int a[N], l[20], p[100], aux[20], aa[20];

int len(int x) {
        int cnt = 0;
        while(x) ++cnt, x /= 10;
        return cnt;
}

int32_t main() {
        ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n; cin >> n;

        p[0] = 1;
        for(int i = 1; i < 100; i++) p[i] = (p[i - 1] * 10) % mod;

        for(int i = 1; i <= n; i++) cin >> a[i], l[len(a[i])]++;

        for(int i = 1; i <= n; i++) aux[i] = (aux[i - 1] + l[i] * p[i]) % mod;

        for(int i = 18; i > 0; i--) {
                aa[i] = l[i];
                l[i] += l[i + 1];
        }

        int sum = 0;
        for(int i = 1; i <= n; i++) {
                int lx = 0;
                while(a[i]) {
                        ++lx;
                        int kx = l[lx], ky = n - l[lx], d = a[i] % 10; a[i] /= 10;
                        sum += ((d * kx) % mod * (11LL * p[(lx - 1) * 2LL]) % mod) % mod;sum %= mod;
                        for(int j = lx - 1; j > 0; j--) {
                                int tx = aa[j];
                                sum += ((d * tx) % mod * (2LL * p[lx - 1 + j]) % mod) % mod;sum %= mod;
                        }
                        sum %= mod;
                }
        }

        cout << sum << endl;

}


#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 100001, mod = 998244353;

int a[N], l[20], p[20], aux[20], aa[20];

int len(int x) {
        int cnt = 0;
        while(x) ++cnt, x /= 10;
        return cnt;
}

int32_t main() {
        ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n; cin >> n;

        p[0] = 1;
        for(int i = 1; i < 20; i++) p[i] = (p[i - 1] * 10) % mod;

        for(int i = 1; i <= n; i++) cin >> a[i], l[len(a[i])]++;

        for(int i = 1; i <= n; i++) aux[i] = (aux[i - 1] + l[i] * p[i]) % mod;

        for(int i = 18; i > 0; i--) {
                aa[i] = l[i];
                l[i] += l[i + 1];
        }

        int sum = 0;
        for(int i = 1; i <= n; i++) {
                int lx = 0;
                while(a[i]) {
                        ++lx;
                        int kx = l[lx], ky = n - l[lx], d = a[i] % 10; a[i] /= 10;
                        sum += ((d * kx) % mod * (11LL * p[(lx - 1) * 2LL]) % mod) % mod;sum %= mod;
                        for(int j = lx - 1; j > 0; j--) {
                                int tx = aa[j];
                                sum += ((d * tx) % mod * (2LL * p[lx - 1 + j]) % mod) % mod;sum %= mod;
                        }
                        sum %= mod;
                }
        }

        cout << sum << endl;

}


#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 100001, mod = 998244353;

int a[N], l[20], p[20], aux[20], aa[20];

int len(int x) {
        int cnt = 0;
        while(x) ++cnt, x /= 10;
        return cnt;
}

int32_t main() {
        ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n; cin >> n;

        p[0] = 1;
        for(int i = 1; i < 20; i++) p[i] = (p[i - 1] * 10) % mod;

        for(int i = 1; i <= n; i++) cin >> a[i], l[len(a[i])]++;

        for(int i = 1; i <= n; i++) aux[i] = (aux[i - 1] + l[i] * p[i]) % mod;

        for(int i = 18; i > 0; i--) {
                aa[i] = l[i];
                l[i] += l[i + 1];
        }

        int sum = 0;
        for(int i = 1; i <= n; i++) {
                int lx = 0, m = 1;
                while(a[i]) {
                        ++lx;
                        int kx = l[lx], ky = n - l[lx], d = a[i] % 10; a[i] /= 10;
                        sum += (d * kx) % mod * ((11) * p[(lx - 1) * 2]) % mod;sum %= mod;
                        for(int j = lx - 1; j > 0; j--) {
                                int tx = aa[j];
                                sum += ((d * tx) % mod * 2 * p[lx - 1 + j]) % mod;sum %= mod;
                        }
                        sum %= mod;
                }
        }

        cout << sum << endl;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int mod=998244353;
typedef long long ll;
int n,m,k,l,s,t,r;
int a[maxn];
int len[maxn];
int has[maxn];
vector<int>p[maxn];

ll ans;
int cal(int x,int y)
{
	ll o=0;
	ll now=1;
	for(int i=0;i<10;i++)
		{
			if(y)
				now*=10,now%=mod,y--;
			now*=10,now%=mod;
			o=(o+p[x][i]*now)%mod;
		}
	return o%mod;
}

int cal_2(int x,int y)
{
	ll o=0;
	ll now=1;
		for(int i=0;i<10;i++)
		{

			now*=10,now%=mod;
			o=(o+p[x][i]*now)%mod;

		if(y)
				now*=10,now%=mod,y--;

		}
	return o%mod;
}

int get_len(int x)
{
	int p=0;
	while(x)
	{
		x/=10;
		p++;
	}
	return p;
}

int main()
{
//	freopen("in.txt","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		len[i]=get_len(a[i]),has[len[i]]++;

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=10;j++)
			p[i].push_back(a[i]%10),a[i]/=10;
	}

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=10;j++)
			ans+=(cal(i,j)*(ll)has[j])%mod,ans%=mod;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=10;j++)
			ans+=(cal_2(i,j)*(ll)has[j])%mod,ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int mod=998244353;
typedef long long ll;
int n,m,k,l,s,t,r;
int a[maxn];
int len[maxn];
int has[maxn];
vector<int>p[maxn];

ll ans;
int cal(int x,int y)
{
	ll o=0;
	ll now=1;
	for(int i=0;i<10;i++)
		{
			if(y)
				now*=10,now%=mod,y--;
			o=(o+p[x][i]*now)%mod;
			now*=10,now%=mod;
		}
	return o%mod;
}

int cal_2(int x,int y)
{
	ll o=0;
	ll now=1;
		for(int i=0;i<10;i++)
		{

			o=(o+p[x][i]*now)%mod;
				now*=10,now%=mod;
			if(y)
				now*=10,now%=mod,y--;
		}
	return o%mod;
}

int get_len(int x)
{
	int p=0;
	while(x)
	{
		x/=10;
		p++;
	}
	return p;
}

int main()
{
	//freopen("in.txt","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		len[i]=get_len(a[i]),has[len[i]]++;

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=10;j++)
			p[i].push_back(a[i]%10),a[i]/=10;
	}

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=10;j++)
			ans+=(cal(i,j)*(ll)has[j])%mod,ans%=mod;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=10;j++)
			ans+=(cal_2(i,j)*(ll)has[j])%mod,ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int mod=998244353;
typedef long long ll;
int n,m,k,l,s,t,r;
int a[maxn];
int len[maxn];
int has[maxn];
ll ans;
int cal(int x,int y)
{
	vector<int>p;
	for(int i=1;i<=10;i++)
		p.push_back(x%10),x/=10;
	vector<int>q;
	for(int i=0;i<10;i++)
		{
			if(y)
				q.push_back(0),y--;
			q.push_back(p[i]);
		}
	ll o=0;
	for(int i=q.size()-1;i>=0;i--)
		o=(o*10ll+q[i])%mod;
	return o%mod;
}

int cal_2(int x,int y)
{
	vector<int>p;
	for(int i=1;i<=10;i++)
		p.push_back(x%10),x/=10;
	vector<int>q;
	for(int i=0;i<10;i++)
		{
			q.push_back(p[i]);
			if(y)
				q.push_back(0),y--;
		}
	ll o=0;
	for(int i=q.size()-1;i>=0;i--)
		o=(o*10+q[i])%mod;
	return o%mod;
}

int get_len(int x)
{
	int p=0;
	while(x)
	{
		x/=10;
		p++;
	}
	return p;
}

int main()
{
//	freopen("in.txt","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		len[i]=get_len(a[i]),has[len[i]]++;
//	cout<<has[0]<<" "<<has[1]<<" "<<has[2]<<endl;
//	cout<<cal(12,2)<<endl;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=10;j++)
			ans+=(cal(a[i],j)*(ll)has[j])%mod,ans%=mod;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=10;j++)
			ans+=(cal_2(a[i],j)*(ll)has[j])%mod,ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int mod=998244353;
typedef long long ll;
int n,m,k,l,s,t,r;
int a[maxn];
int len[maxn];
int has[maxn];
ll ans;
int cal(int x,int y)
{
	vector<int>p;
	for(int i=1;i<=10;i++)
		p.push_back(x%10),x/=10;
	vector<int>q;
	for(int i=0;i<10;i++)
		{
			if(y)
				q.push_back(0),y--;
			q.push_back(p[i]);
		}
	ll o=0;
	for(int i=q.size()-1;i>=0;i--)
		o=o*10ll+q[i];
	return o%mod;
}

int cal_2(int x,int y)
{
	vector<int>p;
	for(int i=1;i<=10;i++)
		p.push_back(x%10),x/=10;
	vector<int>q;
	for(int i=0;i<10;i++)
		{
			q.push_back(p[i]);
			if(y)
				q.push_back(0),y--;
		}
	ll o=0;
	for(int i=q.size()-1;i>=0;i--)
		o=o*10+q[i];
	return o%mod;
}

int get_len(int x)
{
	int p=0;
	while(x)
	{
		x/=10;
		p++;
	}
	return p;
}

int main()
{
//	freopen("in.txt","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		len[i]=get_len(a[i]),has[len[i]]++;
//	cout<<has[0]<<" "<<has[1]<<" "<<has[2]<<endl;
//	cout<<cal(12,2)<<endl;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=10;j++)
			ans+=(cal(a[i],j)*(ll)has[j])%mod,ans%=mod;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=10;j++)
			ans+=(cal_2(a[i],j)*(ll)has[j])%mod,ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
auto ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); };
typedef int_fast64_t LL;
const int MAXN = 1e5+7;
const LL mod = 998244353;
int n;
LL A[MAXN],sum[11][11][2];
vector<LL> digit[11];

int caldigits(LL x){
    int cnt = 0;
    while(x){
        x/=10;
        cnt++;
    }
    return cnt;
}
//3452    x3x4x5x2
LL call(LL x, int k){
    int d = 0;
    LL dig[10];
    while(x){
        dig[d++] = x%10;
        x/=10;
    }
    LL pw = 10;
    for(int i = 0; i < min(k,d); i++){
        x+=dig[i]*pw;
        pw*=100;
    }
    pw/=10;
    for(int i = k;i < d; i++){
        x+=dig[i]*pw;
        pw*=10;
    }
    return x%mod;
}
LL calr(LL x, int k){
    int d = 0;
    LL dig[10];
    while(x){
        dig[d++] = x%10;
        x/=10;
    }
    LL pw = 1;
    for(int i = 0; i < min(k,d); i++){
        x+=dig[i]*pw;
        pw*=100;
    }
    for(int i = k; i < d; i++){
        x+=dig[i]*pw;
        pw*=10;
    }
    return x%mod;
}
int main(){
    ____();
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> A[i];
        digit[caldigits(A[i])].push_back(A[i]);
    }
    for(int i = 1; i < 11; i++){
        for(LL val : digit[i]){                 //长度为i的数字
            for(int j = 1; j < 11; j++){        //和长度为j的数字组合  i为左边
                sum[i][j][0] = (sum[i][j][0]+call(val,j))%mod;
            }
            for(int j = 1; j < 11; j++){        //和长度为j的数字组合  i为右边
                sum[i][j][1] = (sum[i][j][1]+calr(val,j))%mod;
            }
        }
    }
    LL ans = 0;
    for(int i = 1; i < 11; i++){
        if(digit[i].empty()) continue;
        for(int j = 1; j < 11; j++){
            if(digit[j].empty()) continue;
            ans = (ans+(sum[i][j][0]*digit[j].size()+sum[j][i][1]*digit[i].size()))%mod;
        }
    }
    cout << ans << endl;
    return 0;
}


//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
auto ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); };
typedef int_fast64_t LL;
const int MAXN = 1e5+7;
const LL mod = 998244353;
int n;
LL A[MAXN],sum[11][11][2];
vector<LL> digit[11];

int caldigits(LL x){
    int cnt = 0;
    while(x){
        x/=10;
        cnt++;
    }
    return cnt;
}
//3452    x3x4x5x2
LL call(LL x, int k){
    int d = 0;
    LL dig[10];
    while(x){
        dig[d++] = x%10;
        x/=10;
    }
    LL pw = 10;
    for(int i = 0; i < min(k,d); i++){
        x+=dig[i]*pw;
        if(i!=min(k,d)-1) pw*=100;
        pw%=mod;
    }
    pw*=10;
    for(int i = k;i < d; i++){
        x+=dig[i]*pw;
        pw*=10;
        pw%=mod;
    }
    return x%mod;
}
LL calr(LL x, int k){
    int d = 0;
    LL dig[10];
    while(x){
        dig[d++] = x%10;
        x/=10;
    }
    LL pw = 1;
    for(int i = 0; i < min(k,d); i++){
        x+=dig[i]*pw;
        pw*=100;
        pw%=mod;
    }
    for(int i = k; i < d; i++){
        x+=dig[i]*pw;
        pw*=10;
        pw%=mod;
    }
    return x%mod;
}
int main(){
    ____();
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> A[i];
        digit[caldigits(A[i])].push_back(A[i]);
    }
    for(int i = 1; i < 11; i++){
        for(LL val : digit[i]){                 //长度为i的数字
            for(int j = 1; j < 11; j++){        //和长度为j的数字组合  i为左边
                sum[i][j][0] = (sum[i][j][0]+call(val,j))%mod;
            }
            for(int j = 1; j < 11; j++){        //和长度为j的数字组合  i为右边
                sum[i][j][1] = (sum[i][j][1]+calr(val,j))%mod;
            }
        }
    }
    LL ans = 0;
    for(int i = 1; i < 11; i++){
        if(digit[i].empty()) continue;
        for(int j = 1; j < 11; j++){
            if(digit[j].empty()) continue;
            ans = (ans+(sum[i][j][0]*digit[j].size()+sum[j][i][1]*digit[i].size()))%mod;
        }
    }
    cout << ans << endl;
    return 0;
}


//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
auto ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); };
typedef int_fast64_t LL;
const int MAXN = 1e5+7;
const LL mod = 998244353;
int n;
LL A[MAXN],sum[11][11][2];
vector<LL> digit[11];

int caldigits(LL x){
    int cnt = 0;
    while(x){
        x/=10;
        cnt++;
    }
    return cnt;
}
//3452    x3x4x5x2
LL call(LL x, int k){
    int d = 0;
    LL dig[10];
    while(x){
        dig[d++] = x%10;
        x/=10;
    }
    LL pw = 10;
    for(int i = 0; i < min(k,d); i++){
        x+=dig[i]*pw;
        if(i!=min(k,d)-1) pw*=100;
    }
    pw*=10;
    for(int i = k;i < d; i++){
        x+=dig[i]*pw;
        pw*=10;
    }
    return x%mod;
}
LL calr(LL x, int k){
    int d = 0;
    LL dig[10];
    while(x){
        dig[d++] = x%10;
        x/=10;
    }
    LL pw = 1;
    for(int i = 0; i < min(k,d); i++){
        x+=dig[i]*pw;
        pw*=100;
    }
    for(int i = k; i < d; i++){
        x+=dig[i]*pw;
        pw*=10;
    }
    return x%mod;
}
int main(){
    ____();
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> A[i];
        digit[caldigits(A[i])].push_back(A[i]);
    }
    for(int i = 1; i < 11; i++){
        for(LL val : digit[i]){                 //长度为i的数字
            for(int j = 1; j < 11; j++){        //和长度为j的数字组合  i为左边
                sum[i][j][0] = (sum[i][j][0]+call(val,j))%mod;
            }
            for(int j = 1; j < 11; j++){        //和长度为j的数字组合  i为右边
                sum[i][j][1] = (sum[i][j][1]+calr(val,j))%mod;
            }
        }
    }
    LL ans = 0;
    for(int i = 1; i < 11; i++){
        if(digit[i].empty()) continue;
        for(int j = 1; j < 11; j++){
            if(digit[j].empty()) continue;
            ans = (ans+(sum[i][j][0]*digit[j].size()+sum[j][i][1]*digit[i].size()))%mod;
        }
    }
    cout << ans << endl;
    return 0;
}


//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
auto ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); };
typedef int_fast64_t LL;
const int MAXN = 1e5+7;
const LL mod = 998244353;
int n;
LL A[MAXN],sum[10][10][2];
vector<LL> digit[10];

int caldigits(LL x){
    int cnt = 0;
    while(x){
        x/=10;
        cnt++;
    }
    return cnt;
}
//3452    x3x4x5x2
LL call(LL x, int k){
    int d = 0;
    LL dig[10];
    while(x){
        dig[d++] = x%10;
        x/=10;
    }
    LL pw = 10;
    for(int i = 0; i < min(k,d); i++){
        x+=dig[i]*pw;
        pw*=100;
    }
    pw/=10;
    for(int i = k;i < d; i++){
        x+=dig[i]*pw;
        pw*=10;
    }
    return x%mod;
}
LL calr(LL x, int k){
    int d = 0;
    LL dig[10];
    while(x){
        dig[d++] = x%10;
        x/=10;
    }
    LL pw = 1;
    for(int i = 0; i < min(k,d); i++){
        x+=dig[i]*pw;
        pw*=100;
    }
    for(int i = k; i < d; i++){
        x+=dig[i]*pw;
        pw*=10;
    }
    return x%mod;
}
int main(){
    ____();
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> A[i];
        digit[caldigits(A[i])].push_back(A[i]);
    }
    for(int i = 1; i < 10; i++){
        for(LL val : digit[i]){                 //长度为i的数字
            for(int j = 1; j < 10; j++){        //和长度为j的数字组合  i为左边
                sum[i][j][0] = (sum[i][j][0]+call(val,j))%mod;
            }
            for(int j = 1; j < 10; j++){        //和长度为j的数字组合  i为右边
                sum[i][j][1] = (sum[i][j][1]+calr(val,j))%mod;
            }
        }
    }
    LL ans = 0;
    for(int i = 1; i < 10; i++){
        if(digit[i].empty()) continue;
        for(int j = 1; j < 10; j++){
            if(digit[j].empty()) continue;
            ans = (ans+(sum[i][j][0]*digit[j].size()+sum[j][i][1]*digit[i].size()))%mod;
        }
    }
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=1e5+10;
const ll mod=998244353;
ll a[maxn];
vector<int> v[maxn];
int mp[15];
void func(ll x,int pos)
{
    while(x)
    {
        int r=x%10;
        v[pos].push_back(r);
        x/=10;
    }
    mp[v[pos].size()]++;
    //sort(v[pos].rbegin(),v[pos].rend());
}

int main()
{
    int n;
    scanf("%d",&n);
    memset(mp,0,sizeof(mp));
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        func(a[i],i);
    }
//    for(int i=1;i<=n;i++)
//    {
//        for(int j=0;j<v[i].size();j++)
//            printf("%d ",v[i][j]);
//        puts("");
//    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ll t=0;
        int sizee=v[i].size();
        for(int k=1;k<=10;k++)
        {
            if(mp[k]==0)
                continue;
            if(sizee<=k)
            {
                for(int j=0;j<sizee;j++)
                {
                    int pos=2*j+1;
                    ll tt=1;
                    for(int i=1;i<=pos;i++)
                        tt*=10;
                    ll t1=v[i][j]*tt%mod*mp[k]%mod;
                    t=(t+t1)%mod;
                }
            }
            else
            {
                int cnt=2*k;
                for(int j=0;j<sizee;j++)
                {
                    if(j<=k-1)
                    {
                        int pos=2*j+1;
                        ll tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ll t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                    else
                    {
                        int pos=cnt;
                        cnt++;
                        ll tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ll t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                }
            }
        }
        ans=(ans+t)%mod;
    }
    for(int i=1;i<=n;i++)
    {
        ll t=0;
        int sizee=v[i].size();
        for(int k=1;k<=10;k++)
        {
            if(mp[k]==0)
                continue;
            if(sizee<=k)
            {
                for(int j=0;j<v[i].size();j++)
                {
                    int pos=2*j;
                    ll tt=1;
                    for(int i=1;i<=pos;i++)
                        tt*=10;
                    ll t1=v[i][j]*tt%mod*mp[k]%mod;
                    t=(t+t1)%mod;
                }
            }
            else
            {
                int cnt=2*k+1;
                for(int j=0;j<v[i].size();j++)
                {
                    if(j<=k)
                    {
                        int pos=2*j;
                        ll tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ll t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                    else
                    {
                        int pos=cnt;
                        cnt++;
                        ll tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ll t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                }
            }
        }
        ans=(ans+t)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=1e5+10;
const ll mod=998244353;
ll a[maxn];
vector<int> v[maxn];
int mp[15];
void func(ll x,int pos)
{
    while(x)
    {
        int r=x%10;
        v[pos].push_back(r);
        x/=10;
    }
    mp[v[pos].size()]++;
    //sort(v[pos].rbegin(),v[pos].rend());
}

int main()
{
    int n;
    scanf("%d",&n);
    memset(mp,0,sizeof(mp));
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        func(a[i],i);
    }
//    for(int i=1;i<=n;i++)
//    {
//        for(int j=0;j<v[i].size();j++)
//            printf("%d ",v[i][j]);
//        puts("");
//    }
    ull ans=0;
    for(int i=1;i<=n;i++)
    {
        ull t=0;
        int sizee=v[i].size();
        for(int k=1;k<=10;k++)
        {
            if(mp[k]==0)
                continue;
            if(sizee<=k)
            {
                for(int j=0;j<sizee;j++)
                {
                    int pos=2*j+1;
                    ull tt=1;
                    for(int i=1;i<=pos;i++)
                        tt*=10;
                    ull t1=v[i][j]*tt%mod*mp[k]%mod;
                    t=(t+t1)%mod;
                }
            }
            else
            {
                int cnt=2*k;
                for(int j=0;j<sizee;j++)
                {
                    if(j<=k-1)
                    {
                        int pos=2*j+1;
                        ull tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ull t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                    else
                    {
                        int pos=cnt;
                        cnt++;
                        ull tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ull t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                }
            }
        }
        ans=(ans+t)%mod;
    }
    for(int i=1;i<=n;i++)
    {
        ull t=0;
        int sizee=v[i].size();
        for(int k=1;k<=10;k++)
        {
            if(mp[k]==0)
                continue;
            if(sizee<=k)
            {
                for(int j=0;j<v[i].size();j++)
                {
                    int pos=2*j;
                    ull tt=1;
                    for(int i=1;i<=pos;i++)
                        tt*=10;
                    ull t1=v[i][j]*tt%mod*mp[k]%mod;
                    t=(t+t1)%mod;
                }
            }
            else
            {
                int cnt=2*k+1;
                for(int j=0;j<v[i].size();j++)
                {
                    if(j<=k)
                    {
                        int pos=2*j;
                        ull tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ull t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                    else
                    {
                        int pos=cnt;
                        cnt++;
                        ull tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ull t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                }
            }
        }
        ans=(ans+t)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=1e5+10;
const ll mod=998244353;
ll a[maxn];
vector<int> v[maxn];
int mp[10];
void func(ll x,int pos)
{
    while(x)
    {
        int r=x%10;
        v[pos].push_back(r);
        x/=10;
    }
    mp[v[pos].size()]++;
    //sort(v[pos].rbegin(),v[pos].rend());
}

int main()
{
    int n;
    scanf("%d",&n);
    memset(mp,0,sizeof(mp));
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        func(a[i],i);
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ll t=0;
        int sizee=v[i].size();
        for(int k=1;k<=9;k++)
        {
            int cnt=1;
            if(sizee<=k)
            {
                for(int j=0;j<sizee;j++)
                {
                    int pos=2*j+1;
                    ll tt=1;
                    for(int i=1;i<=pos;i++)
                        tt*=10;
                    ll t1=v[i][j]*tt%mod*mp[k]%mod;
                    t=(t+t1)%mod;
                }
            }
            else
            {
                int POS=k-1;
                for(int j=0;j<sizee;j++)
                {
                    if(j<=POS)
                    {
                        int pos=2*j+1;
                        ll tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ll t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                    else
                    {
                        int pos=2*k-1+cnt;
                        ll tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ll t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                }
            }
        }
        ans=(ans+t)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=1e5+10;
const ll mod=998244353;
ll a[maxn];
vector<int> v[maxn];
int mp[15];
void func(ll x,int pos)
{
    while(x)
    {
        int r=x%10;
        v[pos].push_back(r);
        x/=10;
    }
    mp[v[pos].size()]++;
    //sort(v[pos].rbegin(),v[pos].rend());
}

int main()
{
    int n;
    scanf("%d",&n);
    memset(mp,0,sizeof(mp));
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        func(a[i],i);
    }
//    for(int i=1;i<=n;i++)
//    {
//        for(int j=0;j<v[i].size();j++)
//            printf("%d ",v[i][j]);
//        puts("");
//    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ll t=0;
        int sizee=v[i].size();
        for(int k=1;k<=10;k++)
        {
            if(mp[k]==0)
                continue;
            if(sizee<=k)
            {
                for(int j=0;j<sizee;j++)
                {
                    int pos=2*j+1;
                    ll tt=1;
                    for(int i=1;i<=pos;i++)
                        tt*=10;
                    ll t1=v[i][j]*tt%mod*mp[k]%mod;
                    t=(t+t1)%mod;
                }
            }
            else
            {
                int cnt=2*k;
                for(int j=0;j<sizee;j++)
                {
                    if(j<=k-1)
                    {
                        int pos=2*j+1;
                        ll tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ll t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                    else
                    {
                        int pos=cnt;
                        cnt++;
                        ll tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ll t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                }
            }
        }
        ans=(ans+t)%mod;
    }
    for(int i=1;i<=n;i++)
    {
        ll t=0;
        int sizee=v[i].size();
        for(int k=1;k<=10;k++)
        {
            if(mp[k]==0)
                continue;
            if(sizee<=k)
            {
                for(int j=0;j<v[i].size();j++)
                {
                    int pos=2*j;
                    ll tt=1;
                    for(int i=1;i<=pos;i++)
                        tt*=10;
                    ll t1=v[i][j]*tt%mod*mp[k]%mod;
                    t=(t+t1)%mod;
                }
            }
            else
            {
                int cnt=2*k;
                for(int j=0;j<v[i].size();j++)
                {
                    if(j<=k)
                    {
                        int pos=2*j;
                        ll tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ll t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                    else
                    {
                        int pos=cnt;
                        cnt++;
                        ll tt=1;
                        for(int i=1;i<=pos;i++)
                            tt*=10;
                        ll t1=v[i][j]*tt%mod*mp[k]%mod;
                        t=(t+t1)%mod;
                    }
                }
            }
        }
        ans=(ans+t)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


//lsroi
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define maxn 100005
#define Mod 998244353ll
using namespace std;
ll a[maxn],b[maxn][20],co[maxn],c[19];
int main()
{
	c[0]=1ll;
	for(int i=1;i<=18;i++)c[i]=c[i-1]*10ll;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%I64d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
	  ll t=a[i];  co[i]=0;
	  while(t){
	    b[i][++co[i]]=t%10;
	    t/=10;
	  }
	}

	ll ans=0;
	for(int i=1;i<=n;i++)
	{
	  ll l=1,r=0;
	  while(l<=n){
	    r=upper_bound(co+l,co+n+1,co[l])-co-1;
		if(co[i]<=co[l]){
		  for(int j=1;j<=co[i];j++){
		    ans+=c[j-1<<1]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		}
		else {
		  for(int j=1;j<=co[l];j++){
		    ans+=c[j-1<<1]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		  for(int j=co[l]+1;j<=co[i];j++)
		  {
		    ans+=c[(co[l]-1<<1|1)+j-co[l]]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		}
	    l=r+1;
	  }
	}
	for(int i=1;i<=n;i++)
	{
	  ll l=1,r=0;
	  while(l<=n){
	    r=upper_bound(co+l,co+n+1,co[l])-co-1;
		if(co[i]<=co[l]){
		  for(int j=1;j<=co[i];j++){
		    ans+=c[j-1<<1|1]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		}
		else {
		  for(int j=1;j<=co[l];j++){
		    ans+=c[j-1<<1|1]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		  for(int j=co[l]+1;j<=co[i];j++)
		  {
		    ans+=c[(co[l]-1<<1|1)+j-co[l]]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		}
	    l=r+1;
	  }
	}

	printf("%I64d\n",ans%Mod);
	return 0;
}


//lsroi
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define maxn 100005
#define Mod 998244353ll
using namespace std;
ll a[maxn],b[maxn][20],co[maxn],c[19];
int main()
{
	c[0]=1ll;
	for(int i=1;i<=18;i++)c[i]=c[i-1]*10ll;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%I64d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
	  ll t=a[i];  co[i]=0;
	  while(t){
	    b[i][++co[i]]=t%10;
	    t/=10;
	  }
	}

	ll ans=0;
	for(int i=1;i<=n;i++)
	{
	  ll l=1,r=0;
	  while(l<=n){
	    r=upper_bound(co+l,co+n+1,co[l])-co-1;
		if(co[i]<=co[l]){
		  for(int j=1;j<=co[i];j++){
		    ans+=c[j-1<<1]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		}
		else {
		  for(int j=1;j<=co[l];j++){
		    ans+=c[j-1<<1]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		  for(int j=co[l]+1;j<=co[i];j++)
		  {
		    ans+=c[(co[l]-1<<1|1)+j-co[l]]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		}
	    l=r+1;
	  }
	}

	printf("%I64d\n",ans*11ll%Mod);
	return 0;
}


//lsroi
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ull unsigned long long
#define maxn 100005
#define Mod 998244353ll
using namespace std;
ull a[maxn],b[maxn][20],co[maxn],c[20];
int main()
{
	c[0]=1ll;
	for(int i=1;i<=19;i++)c[i]=c[i-1]*10ll;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%I64d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
	  ull t=a[i];  co[i]=0;
	  while(t){
	    b[i][++co[i]]=t%10;
	    t/=10;
	  }
	}

	ull ans=0;
	for(int i=1;i<=n;i++)
	{
	  ull l=1,r=0;
	  while(l<=n){
	    r=upper_bound(co+l,co+n+1,co[l])-co-1;
		if(co[i]<=co[l]){
		  for(int j=1;j<=co[i];j++){
		    ans+=c[j-1<<1]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		}
		else {
		  for(int j=1;j<=co[l];j++){
		    ans+=c[j-1<<1]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		  for(int j=co[l]+1;j<=co[i];j++)
		  {
		    ans+=c[(co[l]-1<<1|1)+j-co[l]]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		}
	    l=r+1;
	  }
	}
	for(int i=1;i<=n;i++)
	{
	  ull l=1,r=0;
	  while(l<=n){
	    r=upper_bound(co+l,co+n+1,co[l])-co-1;
		if(co[i]<=co[l]){
		  for(int j=1;j<=co[i];j++){
		    ans+=c[j-1<<1|1]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		}
		else {
		  for(int j=1;j<=co[l];j++){
		    ans+=c[j-1<<1|1]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		  for(int j=co[l]+1;j<=co[i];j++)
		  {
		    ans+=c[(co[l]-1<<1|1)+j-co[l]]*b[i][j]%Mod*(r-l+1)%Mod;
		    if(ans>=Mod)ans-=Mod;
		  }
		}
	    l=r+1;
	  }
	}

	printf("%I64d\n",ans%Mod);
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define LL long long
#define mod 998244353
#define MAXN 100005
int n;
int a[MAXN];
int tot[MAXN];
int wei[MAXN];
LL result;
int main() {
	scanf ( "%d", &n );
	for ( int i = 1;i <= n;i ++ ) {
		scanf ( "%d", &a[i] );
		int tmp = a[i], cnt = 0;
		while ( tmp ) {
			cnt ++;
			tmp /= 10;
		}
		wei[i] = cnt;
		tot[cnt] ++;
	}
	for ( int i = 1;i <= n;i ++ ) {
	//	printf ( "%d:\n", i );
		for ( int j = 1;j < wei[i];j ++ ) {
			if ( tot[j] == 0 ) continue;
			int x = a[i], cs = 1, many = 1;
			while ( x ) {
				if ( many <= j )
					result = ( result + ( ( x % 10 ) * cs % mod + cs * 10 % mod * ( x % 10 ) % mod ) * tot[j] % mod ) % mod;
				else
					result = ( result + tot[j] * 2 % mod * ( x % 10 ) % mod * cs % mod ) % mod;
				x /= 10;
				if ( many <= j ) cs *= 100;
				else cs *= 10;
				many ++;
			//	printf ( "%d %d %d-----[%d]\n", x, cs, many, result );
			}
		}
		for ( int j = wei[i];j <= 10;j ++ ) {
			if ( tot[j] == 0 ) continue;
			int x = a[i], cs = 1;
			while ( x ) {
				result = ( result + ( ( x % 10 ) * cs % mod + cs * 10 * ( x % 10 ) % mod ) * tot[j] % mod ) % mod;
				//if ( wei[i] == j )
				//	result = ( result - ( ( x % 10 ) * cs % mod + cs * 10 % mod * ( x % 10 ) % mod + mod ) % mod ) % mod;
				x /= 10;
				cs *= 100;
		//		printf ( "%d %d___________-----[%d]\n", x, cs, result );
			}
		}
	}
	printf ( "%lld", result );
	return 0;
}


#include <cstdio>
#include <iostream>
#define MAXW 35
#define MAXN 100005
#define Mod 998244353
#define Int register int
using namespace std;
typedef long long LL;
int cnt[MAXN];
LL a[MAXN], zh[MAXW];
inline void read(LL &x)
{
	x = 0;
	LL f = 1;
	char s = getchar();
	while (s < '0' ||s > '9')
	{
		if (s == '-')
			f = -1;
		s = getchar();
	}
	while (s >= '0' && s <= '9')
	{
		x = (x << 3) + (x << 1) + (s ^ 48);
		s = getchar();
	}
	x *= f;
}
void count(LL x)
{
    int tot = 0;
    while ( x )
    {
        tot ++;
        x /= 10;
    }
    cnt[tot] ++;
}
int main()
{
	LL n;
	read( n );
    zh[1] = 1;
    for (Int i = 2; i < 30; ++ i)
		zh[i] = (zh[i - 1] * 10) % Mod;
    for (Int i = 1; i <= n; ++ i)
    {
        read( a[i] );
        count( a[i] );
    }
    LL Ans = 0;
    for (Int i = 1; i <= n; ++ i)
    {
        LL t = a[i];
		int Index = 0;
        while( t )
        {
            LL num = t % 10;
            t /= 10;
            ++ Index;
            for (Int j = 1; j <= 10; ++ j)
            {
                if (j >= Index)
                {
                    Ans += num * cnt[j] * zh[Index * 2];
                    Ans += num * cnt[j] * zh[Index * 2 - 1];
                }
                else Ans += 2 * num * cnt[j] * zh[Index + j];
            }
            Ans %= Mod;
        }
    }
    printf("%lld", Ans);
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define LL long long
#define mod 998244353
#define MAXN 100005
int n;
int a[MAXN];
int tot[MAXN];
int wei[MAXN];
LL result;
int main() {
	scanf ( "%d", &n );
	for ( int i = 1;i <= n;i ++ ) {
		scanf ( "%d", &a[i] );
		int tmp = a[i], cnt = 0;
		while ( tmp ) {
			cnt ++;
			tmp /= 10;
		}
		wei[i] = cnt;
		tot[cnt] ++;
	}
	for ( int i = 1;i <= n;i ++ ) {
	//	printf ( "%d:\n", i );
		for ( int j = 1;j < wei[i];j ++ ) {
			if ( tot[j] == 0 ) continue;
			int x = a[i], cs = 1, many = 1;
			while ( x ) {
				if ( many <= tot[j] )
					result = ( result + ( x % 10 ) * cs % mod + cs * 10 % mod * ( x % 10 ) % mod * tot[j] % mod ) % mod;
				else
					result = ( result + tot[j] * 2 % mod * ( x % 10 ) % mod * cs % mod ) % mod;
				x /= 10;
				cs *= 100;
				many ++;
			//	printf ( "%d %d %d-----[%d]\n", x, cs, many, result );
			}
		}
		for ( int j = wei[i];j <= 10;j ++ ) {
			if ( tot[j] == 0 ) continue;
			int x = a[i], cs = 1;
			while ( x ) {
				result = ( result + ( ( x % 10 ) * cs % mod + cs * 10 * ( x % 10 ) % mod ) * tot[j] % mod ) % mod;
				//if ( wei[i] == j )
				//	result = ( result - ( ( x % 10 ) * cs % mod + cs * 10 % mod * ( x % 10 ) % mod + mod ) % mod ) % mod;
				x /= 10;
				cs *= 100;
		//		printf ( "%d %d___________-----[%d]\n", x, cs, result );
			}
		}
	}
	printf ( "%lld", result );
	return 0;
}