Magical GCD
시간 제한: 5000ms메모리 제한: 128MB출처: CERC 2013BOJ 9537
문제
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.
입력
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 a1, a2, ..., an, 1 ≤ ai ≤ 1012.
출력
For each test case output one line containing a single integer: the largest Magical GCD of a connected subsequence of the input sequence.
예제
예제 1
입력
1 5 30 60 20 20 20
출력
80
코드를 제출하려면 로그인하세요.