#include using namespace std; using ll = long long; void Yes() {cout << "Yes\n";} void No() {cout << "No\n";} void YES() {cout << "YES\n";} void NO() {cout << "NO\n";} int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int P = 1000000007; int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); if (a[0] == 0) { cout << -1 << endl; return 0; } long long pi = 1; for (int i = 0; i < n; i++) { long long subpi = 1; for (int j = 1; j <= a[i]; j++) { subpi *= j; if (subpi > P) { cout << P << endl; return 0; } } while (subpi--) { pi *= a[i]; if (subpi > P) { cout << P << endl; return 0; } } } cout << P % pi << endl; return 0; }