Under construction

Still being built. Things may change

Planetary Alignment

Interview

Time limit2sMemory limit1024 MB

Summary
Given the alignment periods T_1 to T_(N-2) for each triple of consecutive planets, find the period at which all N planets line up.
Level

Easy3 of 10

Topics
Math, Number theory
Solved
No attempts yet

Problem

Planetary alignment is when planets appear to lie in a straight line. After 18 years, a planetary alignment could be observed from Earth again.

Junseo lives on Earth in a parallel world, where NN planets can be observed. Junseo wants to know how long he must wait to see the moment when all NN planets are lined up in a row.

After watching the sky closely, Junseo found the following facts.

  • There is a moment when the NN planets are lined up in a row.
  • The period of planetary alignment is at most 10910^9 seconds.
  • Planets 1, 2, and 3 line up every T1T_1 seconds.
  • Planets 2, 3, and 4 line up every T2T_2 seconds.
  • ...
  • Planets N−2N-2, N−1N-1, and NN line up every TN−2T_{N-2} seconds.

Find the period of planetary alignment for Junseo.

Input

The first line contains the number of planets NN that should be aligned. (3≤N≤100 0003 \leq N \leq 100\,000)

The second line contains integers T1,T2,⋯ ,TN−2T_1, T_2, \cdots, T_{N-2}, separated by spaces, that give the period at which the planets line up. (1≤Ti≤100 0001 \leq T_i \leq 100\,000)

Output

Print the period of planetary alignment. The period of planetary alignment is at most 10910^9 seconds.

Examples1

  1. Example 1

    Input
    5
    1 2 3
    
    Expected output
    6