Square

시간 제한1초메모리 제한1024 MB

요약
이웃한 곱 a_i*t_i*a_{i+1}*t_{i+1}이 모두 제곱수가 되도록 양의 정수 t_i를 정하고, t_i의 곱의 최솟값을 1e9+7로 나눈 나머지를 구한다.
난이도

보통10점 중 7점

유형
정수론, 수학, 해시맵
정답자
아직 제출이 없습니다

문제

Father Study loves math very much.

Given a sequence of integers a_1,a_2,...,a_na\_1,a\_2,...,a\_n, Father Study wants to calculate another sequence of integers t_1,t_2,...,t_nt\_1,t\_2,...,t\_n satisifing

  • For each i(1≤i≤n)i (1 \le i \le n), t_i>0t\_i > 0.
  • For each i(1≤i<n)i (1\le i < n), a_i×t_i×a_i+1×t_i+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=1nt_i\prod\_{i=1}^{n}{t\_i} is minimized.

Please help Father Study to calculate the answer --- the minimum value of ∏_i=1nt_i\prod\_{i=1}^{n}{t\_i}. Because the answer is too large, please output the answer modulo 10000000071000000007.

입력

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

The second line contains nn integers a_1,a_2,...,a_na\_1, a\_2, ..., a\_n (1≤a_i≤10000001 \le a\_i \le 1000000) separated by single spaces.

출력

Output one integer -- the answer modulo 10000000071000000007.

예제1

  1. 예제 1

    입력
    3
    2 3 6
    
    예상 출력
    6