// #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;
}


### Prompt

Please provide a Cpp coded solution to the problem described below:

Now I have a card with n numbers on it. Consider arranging some or all of these appropriately to make numbers. Find the number obtained by adding all the numbers created at this time.

For example, if you have 1 and 2, you will get 4 numbers 1, 2, 12, 21 so the total number is 36. Even if the same numbers are produced as a result of arranging them, if they are arranged differently, they are added separately. For example, if you have a card called 1 and a card called 11, there are two ways to arrange them so that they are 111, but add them as different ones. There are no leading zero cards among the cards, and we do not accept numbers that lead to zero reading. Output the answer divided by 1,000,000,007.



Input

The input is given in the form:

> n
> a1
> a2
> ...
> an
>

The first line contains n (1 ≤ n ≤ 200), which represents the number of cards, and the next n lines contain the number ai (0 ≤ ai <10000) on each card. Also, the same number is never written on multiple cards.

Output

Output the sum of all the numbers you can make divided by 1,000,000,007 on one line.

Examples

Input

2
1
2


Output

36


Input

2
1
11


Output

234


Input

4
0
4
7
8


Output

135299

### Response

```cpp
// #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;
}


```