@@ -0,0 +1,674 @@
+import sys%0An = int(raw_input())%0Aarr = %5Bint(i) for i in raw_input().strip().split()%5D%0Anum_queries = int(raw_input())%0Aquery_list = %5B%5D%0Afor i in range(num_queries):%0A    query_list.append(raw_input().split())%0Afor i in range(num_queries):%0A    prod = 0%0A    power = 0%0A    low = int(query_list%5Bi%5D%5B0%5D) - 1%0A    high = int(query_list%5Bi%5D%5B1%5D) - 1%0A    maximum = arr%5Blow%5D%0A    minimum = arr%5Blow%5D%0A    for i in range(low,high+1):%0A        if arr%5Bi%5D%3Emaximum:%0A            maximum = arr%5Bi%5D%0A        if arr%5Bi%5D%3Cminimum:%0A            minimum = arr%5Bi%5D%0A    prod = (maximum * minimum) %25 (pow(10,4) + 7)%0A    power = pow(minimum,maximum) %25 (pow(10,4) + 7)%0A    sys.stdout.write(str(prod)+%22 %22+str(power)+%22%5Cn%22)%0A

update hacker rank