CF1165D.Almost All Divisors

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

We guessed some integer number xx . You are given a list of almost all its divisors. Almost all means that there are all divisors except 11 and xx in the list.

Your task is to find the minimum possible integer xx that can be the guessed number, or say that the input data is contradictory and it is impossible to find such number.

You have to answer tt independent queries.

输入格式

The first line of the input contains one integer tt ( 1t251 \le t \le 25 ) — the number of queries. Then tt queries follow.

The first line of the query contains one integer nn ( 1n3001 \le n \le 300 ) — the number of divisors in the list.

The second line of the query contains nn integers d1,d2,,dnd_1, d_2, \dots, d_n ( 2di1062 \le d_i \le 10^6 ), where did_i is the ii -th divisor of the guessed number. It is guaranteed that all values did_i are distinct.

输出格式

For each query print the answer to it.

If the input data in the query is contradictory and it is impossible to find such number xx that the given list of divisors is the list of almost all its divisors, print -1. Otherwise print the minimum possible xx .

输入输出样例

  • 输入#1

    2
    8
    8 2 12 6 4 24 16 3
    1
    2
    

    输出#1

    48
    4
    
首页