Archery
Practice
3.3 (29 votes)
Approved
Easy
Math
Number theory
Problem
70% Success 11600 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

N archers are shooting arrows at targets. There are infinite targets numbered starting with 1. The ith archer shoots at all targets that are multiples of ki.

Find the smallest target that is hit by all the archers.

Input

The first line contains an integer T - the total no. of testc ases.

T test cases follow. Each test case is of the following format:

The first line contains a natural number - N - the number of archers. The second line contains N space-separated integers, where the ith integer denotes the value of ki for the ith archer.

Output

For each test case, print the smallest target that is hit by all archers on a new line.

Constraints

1≤T≤5

1≤N≤15

1≤ki≤48

Sample Input
1
3
2 3 4
Sample Output
12
Explanation

The first archer shoots at targets 2, 4, 6, 8, 10, 12, 14, ...

The second archer shoots at targets 3, 6, 9, 12, ...

The third archer shoots at targets 4, 8, 12, 16, 20, ...

The smallest target at which all archers shoot is 12.

Code Editor

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Submissions
Please login to view your submissions
Similar Problems
Points:30
52 votes
Tags:
Basic ProgrammingNumber theoryBasic Number Theory-1MathNumber Theory
Points:30
262 votes
Tags:
ApprovedEasyMathNumber TheoryReady
Points:30
57 votes
Tags:
ApprovedCombinatoricsEasyException handlingMathNumber TheoryOpenProbabilityStatistics
Editorial

Login to unlock the editorial