prevdiv
You are given a sequence consisting of positive integers. The task is to find the maximum number in the sequence that is exactly divisible by all the numbers that precede it in the sequence. Obviously, the number that appears first in the sequence is divisible by all its predecessors (because it has none). Thus, if the sequence is not empty, there is always a solution to the problem.
Input Files
The first line of input will contain the number of elements in the sequence. The second line will contain the integers of the sequence, separated between them by spaces.
Output Files
The output should consist of a single line containing exactly one integer: the largest number in the sequence that is exactly divisible by all its predecessors in the sequence.
Constraints
Execution time limit: 1 sec.
The least common multiple of all the numbers will not exceed .
Example of Input - Output Files:
STDIN (prevdiv.in)
10
6 3 7 2 6 21 14 42 63 84
STDOUT (prevdiv.out)
42
Comments