using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; public static class P { public static void Main() { int n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split().Select(int.Parse).ToArray(); if (a.Contains(0)) { Console.WriteLine(-1); return; } long res = 1; foreach (var item in a) { long factorial = 1; for (int i = 1; i <= item; i++) { factorial *= i; if (32 <= factorial) goto over; } for (int i = 0; i < factorial; i++) { res *= item; if (1000000007 < factorial) goto over; } } Console.WriteLine(1000000007 % res); return; over:; Console.WriteLine(1000000007); } }