Great Arjit and Numbers
Practice
4 (36 votes)
Algorithms
Approved
Implementation
Math
Medium
Open
Problem
28% Success 7185 Attempts 30 Points 5s Time Limit 256MB Memory 1024 KB Max Code

Arjit is a great coder. He is one of the best all over world. He can solve almost any question.
Arjit's heart falls for a girl Milinda. She came to Arjit with a question.
Given an array Arr, where:
Arr = {X, A[0] * X, A[0] * A[1] * X, A[0] * A[1] * A[2] * X, ... }
where A[i] denotes a number between 1 and 106.

We all know about the notation:

enter image description here

Milinda asks Arjit to find the value of Q.

enter image description here
enter image description here

Arjit is unable to concentrate on the question due to Milinda. Please help him solve this problem.

Input Format:
The first line contains T, the number of test cases.
Each test case consists of 2 lines.
The first line contains N, the size of array Arr.
The second line contains N space separated integers.

Output Format:
For each test case in the input, print the output to MIlinda's query i.e. Q.
Since the answer can be very large output it modulo 10^9 + 7.

Constraints
1 <= T <= 10
1 <= N <= 105
1 <= X <= 106
1 <= Arr[i] <= 109 + 7
Since the values in array Arr can grow quite large the values given will be modulo 109+7

Subtask 1:
T = 10, 1 <= N <= 100 - 25 points

Subtask 2:
Original constraints - 75 points

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
9 votes
Tags:
AlgorithmsMathamaticsBasic Number Theory-1MathNumber Theory
Points:30
936 votes
Tags:
MathMedium
Points:30
20 votes
Tags:
ApprovedCombinatoricsMathMediumOpen