Under construction

Still being built. Things may change

Square

Time limit1sMemory limit1024 MB

Summary
Given a sequence a, choose positive integers t so that each adjacent pair a_i t_i a_{i+1} t_{i+1} is a perfect square, minimizing the product of all t_i modulo 1000000007.
Level

Medium7 of 10

Topics
Number theory, Greedy, Graph
Solved
No attempts yet

Problem

Father Study loves math very much.

Given a sequence of integers a1,a2,…,ana_1, a_2, \ldots, a_n, Father Study wants to calculate another sequence of integers t1,t2,…,tnt_1, t_2, \ldots, t_n that satisfies the following conditions.

  • For each i(1≤i≤n)i (1 \le i \le n), ti>0t_i > 0.
  • For each i(1≤i<n)i (1 \le i < n), ai×ti×ai+1×ti+1a_i \times t_i \times a_{i+1} \times t_{i+1} is a square number. (In mathematics, a square number or perfect square is an integer that is the square of an integer, in other words, it is the product of some integer with itself.)
  • ∏i=1nti\prod_{i=1}^{n}{t_i} is minimized.

Find the minimum value of ∏i=1nti\prod_{i=1}^{n}{t_i}.

Input

The first line contains a single integer nn (1≤n≤1000001 \le n \le 100000).

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤10000001 \le a_i \le 1000000) separated by single spaces.

Output

Output one integer, the minimum value of ∏i=1nti\prod_{i=1}^{n}{t_i} modulo 10000000071000000007.

Examples1

  1. Example 1

    Input
    3
    2 3 6
    
    Expected output
    6