use std::io::*; const MOD: i64 = 1_000_000_007; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let a: Vec = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let mp = |mut x: i64, mut e: i64| -> i64 { let mut res = 1; while e > 0 { if e & 1 == 1 { res = res * x % MOD; } x = x * x % MOD; e >>= 1; } res }; let mut s = vec![0i64; n + 1]; let mut r = 0; let mut now = 1; for l in 0..n { while r < n && now * a[r] < 1_000_000_000 { now *= a[r]; r += 1; } for i in 0..r - l { s[l + i] += (r - l - i) as i64; } if l == r { r += 1; } now /= a[l]; } let mut ans = 1; for i in 0..n { ans = ans * mp(a[i], s[i]) % MOD; } println!("{}", ans); }