// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

ll dp[201][805], tmp[201][805];
ll pw[805], tab[201], tab_zero[201];
 
signed main() {
    int N; cin >> N;
    pw[0] = 1;
    for(int i=1; i<805; i++) {
        pw[i] = (pw[i-1] * 10) % MOD;
    }

    // tab[i] = iP0 + iP1 + ... iPi
    for(int i=0; i<=N; i++) {
        tab[i] = 1;
        ll P = 1;
        for(int k=1; k<=i; k++) {
            (P *= i - k + 1) %= MOD;
            (tab[i] += P) %= MOD;
            (tab_zero[i] += P * k % MOD) %= MOD;
        }
    }

    bool exist_zero = false;
    vector<int> A, digits;
    for(int i=0; i<N; i++) {
        int val; cin >> val;
        if(val == 0) {
            exist_zero = true;
            continue;
        }
        else A.push_back(val);

        int d = 0; while(val) d++, val /= 10;
        digits.push_back(d);
    }

    int M = A.size(), sum = 0;
    dp[0][0] = 1;
    for(int i=0; i<M; i++) {
        for(int j=i; j>=0; j--) {
            for(int k=sum; k>=0; k--) {
                (dp[j+1][k+digits[i]] += dp[j][k] * (j + 1)) %= MOD;
            }
        }
        sum += digits[i];
    }

    // i 番目を使わない場合
    ll ans = 0, show_debug = false;
    for(int i=0; i<M; i++) {
        fill(tmp[0], tmp[M+1], 0);
        for(int j=0; j<M; j++) {
            for(int k=0; k<=sum; k++) {
                tmp[j][k] = dp[j][k];
                if(j - 1 >= 0 and k - digits[i] >= 0) {
                    (tmp[j][k] += MOD - (tmp[j-1][k - digits[i]] * j % MOD)) %= MOD;
                }

                // j 個を使って合計 k 桁 (これを i 番目の下に置くイメージ)
                // 残っているのは M-j-1 個
                {
                    // 0 を使わない場合
                    ll comb = tab[M-j-1] * tmp[j][k] % MOD;
                    ll val = A[i] * pw[k] % MOD;
                    ll add = val * comb % MOD;
                    (ans += add) %= MOD;
                    // fprintf(stderr, "val = %d, comb = %lld * %lld\n", val, tab[M-j-1], tmp[j][k]);
                    if(add and show_debug) fprintf(stderr, "#1: i = %d, j = %d, k = %d, add = %lld\n", i, j, k, add);
                }

                if(exist_zero) {
                    // 0 を使う場合 (i 番目の下に置く)
                    {
                        ll comb = tab[M-j-1] * tmp[j][k] % MOD * (j+1) % MOD;
                        ll val = A[i] * pw[k + 1] % MOD;
                        ll add = val * comb % MOD;
                        (ans += add) %= MOD;
                        if(add and show_debug) fprintf(stderr, "#2: i = %d, j = %d, k = %d, add = %lld\n", i, j, k, add);
                    }

                    // 0 を使う場合 (i 番目の上に置く)
                    {
                        ll comb = tab_zero[M-j-1] * tmp[j][k] % MOD;
                        ll val = A[i] * pw[k] % MOD;
                        ll add = val * comb % MOD;
                        (ans += add) %= MOD;
                        if(add and show_debug) fprintf(stderr, "#3: i = %d, j = %d, k = %d, add = %lld\n", i, j, k, add);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5692