object Solution { def main(args: Array[String]) { val in = readLine.split(" ").map(x=>x.toLong) val m = 1000000007L def powmod (a: Long, n: Long, m: Long) : Long = { if (n == 1) a % m else {val v = powmod(a, n/2, m); if (n%2==0) (v*v)%m else (((v * v) % m) * a) % m; } } println(powmod((in.head+in.drop(1).head)/2, in.drop(2).head, m)) } }