#define _CRT_SECURE_NO_WARNINGS #define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING #include using namespace std; using ll = long long; using ull = unsigned long long; ull fac[] = {1ull, 1ull, 2ull, 6ull, 24ull, 120ull, 720ull, 5040ull, 40320ull, 362880ull, 3628800ull, 39916800ull, 479001600ull, 6227020800ull, 87178291200ull, 1307674368000ull, 20922789888000ull, 355687428096000ull, 6402373705728000ull, 121645100408832000ull}; ull _11[] = {1ull, 1ull, 11ull, 111ull, 1111ull, 11111ull, 111111ull, 1111111ull, 11111111ull, 111111111ull, 1111111111ull, 11111111111ull, 111111111111ull, 1111111111111ull, 11111111111111ull, 111111111111111ull, 1111111111111111ull, 11111111111111111ull, 111111111111111111ull, 1111111111111111111ull}; int main() { int n, num[10]; while (scanf("%d", &n), n) { memset(num, 0, sizeof(num)); int sum = 0; for (int i = 0, x; i < n; i++) scanf("%d", &x), num[x]++, sum += x; ull ans = fac[n]; for (int i = 0; i < 10; i++) ans /= fac[num[i]]; printf("%lld\n", ans * sum * _11[n] / n); } return 0; }