#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 7;
const int maxp = 12;
const ll mod = 998244353;
ll mult = 1LL*100;
vector<ll> pow10(maxp);

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    ll curpow = 1LL;
    for (int i = 0; i < maxp; i++) {
        pow10[i] = curpow;
        curpow *= 1LL*10;
        curpow %= mod;
    }

    int n; cin >> n;

    vector<string> v(n);
    vector<int> cnt(maxp, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        reverse(v[i].begin(),v[i].end());
        int len = (int)v[i].size();
        cnt[len]++;
    }

    for (int i = maxp-1; i > 0; i--) {
        cnt[i-1] += cnt[i];
    }

    ll ans = 0LL;

    for (int i = 0; i < n; i++) {
        ll cur = 1LL;
        for (int j = 0; j < (int)v[i].size(); j++) {
            ll dig = 1LL*(v[i][j]-'0');
            ll tmpcur = cur;
            ll tot = 0LL;
            for (int k = j; k >= 0; k--) {
                ll val = dig*tmpcur*(cnt[k]-tot);
                val %= mod;
                ans += val;
                ans %= mod;
                tmpcur /= 10LL;
                tot = cnt[k];
                if (tot == n) break;
            }
            cur *= 1LL*100;
            cur %= mod;
        }

        cur = 10LL;
        for (int j = 0; j < (int)v[i].size(); j++) {
            ll dig = 1LL*(v[i][j]-'0');
            ll tmpcur = cur;
            ll tot = 0LL;
            for (int k = j+1; k >= 0; k--) {
                ll val = dig*tmpcur*(cnt[k]-tot);
                val %= mod;
                ans += val;
                ans %= mod;
                tmpcur /= 10LL;
                tot = cnt[k];
                if (tot == n) break;
            }
            cur *= 1LL*100;
            cur %= mod;
        }
    }

    out(ans);
    
    
    return 0;
}
