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

using pii = pair<int, int>;
using ll = long long;

constexpr ll M = 1e9 + 7;

ll ten_pow[1024];
ll fact[256];
ll comb[256][256];

void init() {
    ten_pow[0] = 1;
    for(int i = 1; i < 1024; ++i) {
        ten_pow[i] = (ten_pow[i - 1] * 10) % M;
    }
    fact[0] = 1;
    for(int i = 1; i < 256; ++i) {
        fact[i] = (fact[i - 1] * i) % M;
    }
    for(int i = 0; i < 256; ++i) {
        for(int j = 0; j < 256; ++j) {
            if(i == j || j == 0) {
                comb[i][j] = 1;
            } else {
                comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % M;
            }
        }
    }
}

ll solve(vector<int> const& a, vector<int> const& d) {
    int const n = a.size();

    vector<vector<vector<ll>>> dp(5, vector<vector<ll>>(n, vector<ll>(n * 4 + 1)));
    ll res = 0;
    vector<ll> sum(5);
    for(int i = 0; i < n; ++i) {
        sum[d[i]] = (sum[d[i]] + a[i]) % M;
    }
    for(int i = 0; i < n; ++i) {
        if(dp[d[i]][0][0] == 0) {
            dp[d[i]][0][0] = 1;
            for(int j = 0; j < n; ++j) {
                if(i == j) {
                    continue;
                }
                for(int k = n - 1; k >= 0; --k) {
                    for(int l = 0; l < n * 4 + 1; ++l) {
                        if(dp[d[i]][k][l] == 0) {
                            continue;
                        }
                        dp[d[i]][k + 1][l + d[j]] = (dp[d[i]][k + 1][l + d[j]] + dp[d[i]][k][l] * (k + 1)) % M;
                    }
                }
            }
        }
    }
    for(int i = 1; i < 5; ++i) {
        for(int j = 0; j < n; ++j) {
            for(int k = 0; k < 4 * n + 1; ++k) {
                if(dp[i][j][k] == 0) {
                    continue;
                }
                for(int l = 0; l <= n - 1 - j; ++l) {
                    ll t = (sum[i] * dp[i][j][k]) % M;
                    t = (t * ten_pow[k]) % M;
                    t = (t * comb[n - 1 - j][l]) % M;
                    t = (t * fact[l]) % M;
                    res = (res + t) % M;
                }
            }
        }
    }

    return res;
}

int main() {
    init();

    int n;
    cin >> n;
    int zero_cnt = 0;
    vector<int> a(n);
    vector<int> d(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        d[i] = to_string(a[i]).size();
        zero_cnt += (a[i] == 0);
    }

    ll res = solve(a, d);
    if(zero_cnt != 0) {
        int idx = find(begin(a), end(a), 0) - begin(a);
        a.erase(a.begin() + idx);
        d.erase(d.begin() + idx);
        ll leading_zero = (zero_cnt * solve(a, d)) % M;
        res = (res - leading_zero + M) % M;
    }

    cout << res << endl;
}

### Prompt

In Cpp, your task is to solve the following problem:

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
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;
using ll = long long;

constexpr ll M = 1e9 + 7;

ll ten_pow[1024];
ll fact[256];
ll comb[256][256];

void init() {
    ten_pow[0] = 1;
    for(int i = 1; i < 1024; ++i) {
        ten_pow[i] = (ten_pow[i - 1] * 10) % M;
    }
    fact[0] = 1;
    for(int i = 1; i < 256; ++i) {
        fact[i] = (fact[i - 1] * i) % M;
    }
    for(int i = 0; i < 256; ++i) {
        for(int j = 0; j < 256; ++j) {
            if(i == j || j == 0) {
                comb[i][j] = 1;
            } else {
                comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % M;
            }
        }
    }
}

ll solve(vector<int> const& a, vector<int> const& d) {
    int const n = a.size();

    vector<vector<vector<ll>>> dp(5, vector<vector<ll>>(n, vector<ll>(n * 4 + 1)));
    ll res = 0;
    vector<ll> sum(5);
    for(int i = 0; i < n; ++i) {
        sum[d[i]] = (sum[d[i]] + a[i]) % M;
    }
    for(int i = 0; i < n; ++i) {
        if(dp[d[i]][0][0] == 0) {
            dp[d[i]][0][0] = 1;
            for(int j = 0; j < n; ++j) {
                if(i == j) {
                    continue;
                }
                for(int k = n - 1; k >= 0; --k) {
                    for(int l = 0; l < n * 4 + 1; ++l) {
                        if(dp[d[i]][k][l] == 0) {
                            continue;
                        }
                        dp[d[i]][k + 1][l + d[j]] = (dp[d[i]][k + 1][l + d[j]] + dp[d[i]][k][l] * (k + 1)) % M;
                    }
                }
            }
        }
    }
    for(int i = 1; i < 5; ++i) {
        for(int j = 0; j < n; ++j) {
            for(int k = 0; k < 4 * n + 1; ++k) {
                if(dp[i][j][k] == 0) {
                    continue;
                }
                for(int l = 0; l <= n - 1 - j; ++l) {
                    ll t = (sum[i] * dp[i][j][k]) % M;
                    t = (t * ten_pow[k]) % M;
                    t = (t * comb[n - 1 - j][l]) % M;
                    t = (t * fact[l]) % M;
                    res = (res + t) % M;
                }
            }
        }
    }

    return res;
}

int main() {
    init();

    int n;
    cin >> n;
    int zero_cnt = 0;
    vector<int> a(n);
    vector<int> d(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        d[i] = to_string(a[i]).size();
        zero_cnt += (a[i] == 0);
    }

    ll res = solve(a, d);
    if(zero_cnt != 0) {
        int idx = find(begin(a), end(a), 0) - begin(a);
        a.erase(a.begin() + idx);
        d.erase(d.begin() + idx);
        ll leading_zero = (zero_cnt * solve(a, d)) % M;
        res = (res - leading_zero + M) % M;
    }

    cout << res << endl;
}

```