#include #include #include using namespace std; int main() { int N; while (cin >> N) { vector T(N); for (auto& t : T) cin >> t; vector dyn(100); dyn[0] = 1; for (auto& t : T) { vector dyn2(100); for (int x = 0; x < 100; x++) if (dyn[x]) for (int y = 0; y < 100; y++) { if (y >= t || (x%10)*10+(y/10) >= t || (x%10)*10+(y%10) >= t) continue; dyn2[y] += dyn[x]; } dyn.swap(dyn2); } int64_t ret = 1; for (auto t : T) ret *= t; for (auto d : dyn) ret -= d; cout << ret << endl; } }