## Problem

Alexey is trying to develop a program for a very simple microcontroller. It makes readings from various sensors over time, and these readings must happen at specific regular times. Unfortunately, if two of these readings occur at the same time, the microcontroller freezes and must be reset.

There areÂ **N**Â different sensors that read data on a regular basis. For eachÂ **i**Â fromÂ **1**Â toÂ **N**, the reading from sensorÂ **i**Â will occur everyÂ **A _{i}**Â milliseconds with the first reading occurring exactlyÂ

**A**Â milliseconds after the microcontroller is powered up. Each reading takes precisely one millisecond on Alexeyâ€™s microcontroller.

_{i}Alexey wants to know when the microcontroller will freeze after he turns it on.

### Input

The first line of the input contains an integerÂ **T**Â denoting the number of test cases. The description ofÂ **T**Â test cases follows.

The first line contains single integerÂ **N**Â denoting the number of sensors.

The second line containsÂ **N**Â space-separated integersÂ **A _{1}, A_{2}, â€¦, A_{N}**Â denoting frequency of measurements. Namely, sensorÂ

**i**Â will be read everyÂ

**A**Â milliseconds with the first reading occurringÂ

_{i}**A**Â milliseconds after the microcontroller is first turned on.

_{i}### Output

For each test case, output a single line containing the number of milliseconds until the microcontroller freezes.

### Constraints

**1**Â â‰¤Â**T**Â â‰¤Â**10****2**Â â‰¤Â**N**Â â‰¤Â**500****1**Â â‰¤Â**A**Â â‰¤Â_{i}**10**^{9}

### Subtasks

Subtask #1 (10 points)Â **1Â **â‰¤Â **T**Â â‰¤Â **10,****2**Â â‰¤Â **N**Â â‰¤Â **9**,Â **1**Â â‰¤Â **A _{i}**Â â‰¤Â

**500**Subtask #2 (20 points)Â

**1Â**â‰¤Â

**T**Â â‰¤Â

**10,**

**2**Â â‰¤Â

**N**Â â‰¤Â

**500,**

**1**Â â‰¤Â

**A**Â â‰¤Â

_{i}**1000**Subtask #3 (70 points)Â

**original constraints**

### Sample Input 1

```
3
3
2 3 5
4
1 8 7 11
4
4 4 5 6
```

### Sample Output 1

```
6
7
4
```

### Explanation

**Case 1: in 6 milliseconds, the third reading will be attempted from the 1st sensor and the second reading will be attempted from the 2nd sensor**.

**Case 2: in 7 milliseconds the seventh reading will be attempted from the 1st sensor and the first reading will be attempted from the 3rd sensor**.

**Case 3: in 4 milliseconds, the first readings from the first two sensors will be attempted**.

## Task for Alexey â€“ CodeChef Solution in JAVA

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for (int tc = 0; tc < T; tc++) { int N = sc.nextInt(); int[] A = new int[N]; for (int i = 0; i < A.length; i++) { A[i] = sc.nextInt(); } System.out.println(solve(A)); } sc.close(); } static long solve(int[] A) { long result = Long.MAX_VALUE; for (int i = 0; i < A.length; i++) { for (int j = i + 1; j < A.length; j++) { result = Math.min(result, lcm(A[i], A[j])); } } return result; } static long lcm(int a, int b) { return (long) a / gcd(a, b) * b; } static int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); } }

** Disclaimer:Â The above Problem (Task for Alexey) is generated by**Â CodeChef but the solution is provided byÂ

**Chase2learn**.This tutorial is only forÂ

**Educational**Â andÂ

**Learning**Â purpose.