import std.stdio; import std.string; import std.algorithm; import std.array; import std.conv; import std.range; import std.math; const int D = 1000000007; void main() { readln; // discard N int[] a = readln.strip.split(" ").map!(to!int).array; if (a.reduce!(min) <= 0) { writeln("-1"); return; } int m = 1; foreach (ai; a) { if (4 <= ai) { writeln(D); return; } int factor = ai.iota.map!("a+1").reduce!("a*b"); m *= pow(ai, factor); if (D <= m) { writeln(D); return; } } writeln(D % m); }