#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long

using namespace std;

int inv[805], fac[805], finv[805];

void make()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2;i<805;i++){
        inv[i] = MOD - (ll)inv[MOD%i] * (MOD/i) % MOD;
        fac[i] = (ll)fac[i-1] * i % MOD;
        finv[i] = (ll)finv[i-1] * inv[i] % MOD;
    }
}

int comb(int a, int b)
{
    if(a < b){
        return 0;
    }else{
        return fac[a] * ((ll)finv[b] * finv[a-b] % MOD) % MOD;
    }
}

int add(int a, int b)
{
    return (a + b) % MOD;
}

int sub(int a, int b)
{
    return (a - b + MOD) % MOD;
}

int mul(int a, int b)
{
    return (ll)a*b%MOD;
}

// i 個で j 桁の数で 0 含む
int dp[205][805], dp2[205][805];
int a[205], keta[205];
int zyu[805];
int bar[205];

int dig(int num)
{
    int res = 1;
    while(num >= 10){
        res++;
        num /= 10;
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int zero = 0, wa = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0) zero++;
        keta[i] = dig(a[i]);
    }
    zyu[0] = 1;
    for(int i = 0; i < 804; i++){
        zyu[i+1] = mul(zyu[i], 10);
    }
    dp[0][0] = 1;
    for(int k = 0; k < n; k++){
        for(int i = k; i >= 0; i--){
            for(int j = 0; j <= wa; j++){
                dp[i+1][j+keta[k]] = add(dp[i+1][j+keta[k]], mul(dp[i][j], i+1));
            }
        }
        wa += keta[k];
    }
    make();
    for(int i = 0; i < 205; i++){
        for(int j = 0; j <= i; j++){
            bar[i] = add(bar[i], mul(fac[i], finv[i-j]));
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == 0) continue;
        for(int j = 0; j <= n; j++){
            for(int k = 0; k <= wa; k++){
                dp2[j][k] = dp[j][k];
            }
        }
        for(int j = 0; j < n; j++){
            for(int k = 0; k <= wa-keta[i]; k++){
                dp2[j+1][k+keta[i]] = sub(dp2[j+1][k+keta[i]], mul(dp2[j][k], j+1));
            }
        }
        for(int j = 0; j <= n-1; j++){
            for(int k = 0; k <= wa-keta[i]; k++){
                ans = add(ans, mul(mul(dp2[j][k], bar[n-j-1]), mul(a[i], zyu[k])));
            }
        }
    }
    if(zero == 0){
        cout << ans << "\n";
    }else{
        vector<int> A;
        vector<int> ket;
        bool flag = false;
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= wa; j++){
                dp[i][j] = 0;
            }
        }
        for(int i = 0; i < n; i++){
            if(a[i] == 0 && !flag){
                flag = true;
                continue;
            }
            A.push_back(a[i]);
            ket.push_back(dig(A.back()));
        }
        --n;
        dp[0][0] = 1;
        int wa = 0;
        for(int k = 0; k < n; k++){
            for(int i = k; i >= 0; i--){
                for(int j = 0; j <= wa; j++){
                    dp[i+1][j+ket[k]] = add(dp[i+1][j+ket[k]], mul(dp[i][j], i+1));
                }
            }
            wa += ket[k];
        }
        int ans1 = 0;
        for(int i = 0; i < n; i++){
            if(A[i] == 0) continue;
            for(int j = 0; j <= n; j++){
                for(int k = 0; k <= wa; k++){
                    dp2[j][k] = dp[j][k];
                }
            }
            for(int j = 0; j < n; j++){
                for(int k = 0; k <= wa-ket[i]; k++){
                    dp2[j+1][k+ket[i]] = sub(dp2[j+1][k+ket[i]], mul(dp2[j][k], j+1));
                }
            }
            for(int j = 0; j <= n-1; j++){
                for(int k = 0; k <= wa-ket[i]; k++){
                    ans1 = add(ans1, mul(mul(dp2[j][k], bar[n-j-1]), mul(A[i], zyu[k])));
                }
            }
        }
        cout << sub(ans, mul(zero, ans1)) << "\n";
    }
}



Measured memory_bytes: 4464