#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int main() { ll limit = 1000000007; int n; cin >> n; ll num = 1; for(int i = 0; i < n; i++) { ll tmp, a; cin >> a; if(a < 2) { continue; } tmp = a; while(tmp--) { for(int j = 0; j < tmp + 1; j++) { num *= a; if(num > limit) { cout << limit << '\n'; return 0; } } } } if(limit % num == 0) { cout << -1 << '\n'; } else { cout << limit % num << '\n'; } return 0; }