Problem8380--uVA1642 - Magical GCD

8380: uVA1642 - Magical GCD

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

The Magical GCD of a nonempty sequence of positive integers is defined as the product of its length and the greatest common divisor of all its elements. 
Given a sequence (a1, . . . , an), find the largest possible Magical GCD of its connected subsequence.

给定一个长度为 $n\ (n≤10^5)$,每个数 $a_i\ (a_i≤10^{12})$,找一个连续子序列使得子序列的公约数与长度的乘积最大。

Input

The first line of input contains the number of test cases T. 
The descriptions of the test cases follow: 
The description of each test case starts with a line containing a single integer $n\ (1 ≤ n ≤ 100,000)$. 
The next line contains the sequence $a_1, a_2, \cdots , a_n\ (1 ≤ a_i ≤ 10^{12})$.

Output

For each test case output one line containing a single integer: the largest Magical GCD of a connected subsequence of the input sequence. 

Sample 1 Input

1
5
30 60 20 20 20

Sample 1 Output

80

HINT

相同题目:UVA-1642

Source/Category