#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
using namespace std;
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif
typedef long long ll;
const int N = (int)1e5 + 10;
const ll INF = (ll)1e18;
const int LOG = 17;
ll a[N];
ll sparse[LOG][N];
int h[N];
int n;
ll gcd(ll x, ll y)
{
return y == 0 ? x : gcd(y, x % y);
}
ll cheatGcd(ll x, ll y)
{
return 1;
return y == 0 ? x : gcd(y, x % y);
}
void read()
{
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%lld", &a[i]);
}
void calcSparse()
{
for (int i = 0; i < LOG; i++)
{
for (int s = 0; s <= n - (1 << i); s++)
{
if (i == 0)
sparse[i][s] = a[s];
else
sparse[i][s] = gcd(sparse[i - 1][s], sparse[i - 1][s + (1 << (i - 1))]);
}
}
}
ll getCheatGcd(int l, int r)
{
int t = h[r - l + 1];
return cheatGcd(sparse[t][l], sparse[t][r - (1 << t) + 1]);
}
void calcH()
{
h[1] = 0;
for (int i = 2; i < N; i++)
h[i] = h[i / 2] + 1;
}
void solve()
{
MaxValue = -INF;
for (int i = 0; i < n; i++)
MaxValue = max(MaxValue, a[i]);
calcSparse();
calcH();
ll ans = MaxValue;
for (int i = 0; i < n; i++)
{
int t = i;
while (t < n)
{
ll curGcd = getCheatGcd(i, t);
int l = t, r = n;
while (r - l > 1)
{
int mid = (l + r) / 2;
if (getCheatGcd(i, mid) != curGcd)
r = mid;
else
l = mid;
}
ans = max(ans, curGcd * (r - i));
if (curGcd == 1)
break;
t = r;
}
}
printf("%lld\n", ans);
}
int main()
{
#ifdef LOCAL
freopen ("input.txt", "r", stdin);
freopen ("output.txt", "w", stdout);
#endif
int T;
scanf("%d", &T);
for (int i = 0; i < T; i++)
{
read();
solve();
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jb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pKTsKCQkJaWYgKGN1ckdjZCA9PSAxKQoJCQkJYnJlYWs7CgkJCXQgPSByOwoJCX0KCX0KCXByaW50ZigiJWxsZFxuIiwgYW5zKTsKfQoKaW50IG1haW4oKQp7CiNpZmRlZiBMT0NBTAoJZnJlb3BlbiAoImlucHV0LnR4dCIsICJyIiwgc3RkaW4pOwoJZnJlb3BlbiAoIm91dHB1dC50eHQiLCAidyIsIHN0ZG91dCk7CiNlbmRpZgoJaW50IFQ7CglzY2FuZigiJWQiLCAmVCk7Cglmb3IgKGludCBpID0gMDsgaSA8IFQ7IGkrKykKCXsKCQlyZWFkKCk7CgkJc29sdmUoKTsKCX0KCXJldHVybiAwOwp9
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:1: error: class, interface, or enum expected
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <cstdio>
^
Main.java:3: error: illegal character: '#'
#include <cstdlib>
^
Main.java:4: error: illegal character: '#'
#include <cstring>
^
Main.java:5: error: illegal character: '#'
#include <string>
^
Main.java:6: error: illegal character: '#'
#include <vector>
^
Main.java:7: error: illegal character: '#'
#include <algorithm>
^
Main.java:8: error: illegal character: '#'
#include <set>
^
Main.java:9: error: illegal character: '#'
#include <map>
^
Main.java:10: error: illegal character: '#'
#include <cmath>
^
Main.java:11: error: illegal character: '#'
#include <ctime>
^
Main.java:14: error: illegal character: '#'
#ifdef LOCAL
^
Main.java:15: error: illegal character: '#'
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
^
Main.java:16: error: illegal character: '#'
#else
^
Main.java:17: error: illegal character: '#'
#define eprintf(...) 42
^
Main.java:18: error: illegal character: '#'
#endif
^
Main.java:21: error: class, interface, or enum expected
const int N = (int)1e5 + 10;
^
Main.java:22: error: class, interface, or enum expected
const ll INF = (ll)1e18;
^
Main.java:23: error: class, interface, or enum expected
const int LOG = 17;
^
Main.java:24: error: class, interface, or enum expected
ll MaxValue, Border;
^
Main.java:25: error: class, interface, or enum expected
ll a[N];
^
Main.java:26: error: class, interface, or enum expected
ll sparse[LOG][N];
^
Main.java:27: error: class, interface, or enum expected
int h[N];
^
Main.java:28: error: class, interface, or enum expected
int n;
^
Main.java:30: error: class, interface, or enum expected
ll gcd(ll x, ll y)
^
Main.java:33: error: class, interface, or enum expected
}
^
Main.java:39: error: class, interface, or enum expected
return y == 0 ? x : gcd(y, x % y);
^
Main.java:40: error: class, interface, or enum expected
}
^
Main.java:45: error: class, interface, or enum expected
for (int i = 0; i < n; i++)
^
Main.java:45: error: class, interface, or enum expected
for (int i = 0; i < n; i++)
^
Main.java:45: error: class, interface, or enum expected
for (int i = 0; i < n; i++)
^
Main.java:47: error: class, interface, or enum expected
}
^
Main.java:51: error: class, interface, or enum expected
for (int i = 0; i < LOG; i++)
^
Main.java:51: error: class, interface, or enum expected
for (int i = 0; i < LOG; i++)
^
Main.java:53: error: class, interface, or enum expected
for (int s = 0; s <= n - (1 << i); s++)
^
Main.java:53: error: class, interface, or enum expected
for (int s = 0; s <= n - (1 << i); s++)
^
Main.java:57: error: class, interface, or enum expected
else
^
Main.java:59: error: class, interface, or enum expected
}
^
Main.java:66: error: class, interface, or enum expected
return cheatGcd(sparse[t][l], sparse[t][r - (1 << t) + 1]);
^
Main.java:67: error: class, interface, or enum expected
}
^
Main.java:72: error: class, interface, or enum expected
for (int i = 2; i < N; i++)
^
Main.java:72: error: class, interface, or enum expected
for (int i = 2; i < N; i++)
^
Main.java:72: error: class, interface, or enum expected
for (int i = 2; i < N; i++)
^
Main.java:74: error: class, interface, or enum expected
}
^
Main.java:79: error: class, interface, or enum expected
for (int i = 0; i < n; i++)
^
Main.java:79: error: class, interface, or enum expected
for (int i = 0; i < n; i++)
^
Main.java:79: error: class, interface, or enum expected
for (int i = 0; i < n; i++)
^
Main.java:81: error: class, interface, or enum expected
Border = MaxValue / (n + 1);
^
Main.java:83: error: class, interface, or enum expected
calcSparse();
^
Main.java:84: error: class, interface, or enum expected
calcH();
^
Main.java:85: error: class, interface, or enum expected
ll ans = MaxValue;
^
Main.java:86: error: class, interface, or enum expected
for (int i = 0; i < n; i++)
^
Main.java:86: error: class, interface, or enum expected
for (int i = 0; i < n; i++)
^
Main.java:86: error: class, interface, or enum expected
for (int i = 0; i < n; i++)
^
Main.java:89: error: class, interface, or enum expected
while (t < n)
^
Main.java:92: error: class, interface, or enum expected
int l = t, r = n;
^
Main.java:93: error: class, interface, or enum expected
while (r - l > 1)
^
Main.java:96: error: class, interface, or enum expected
if (getCheatGcd(i, mid) != curGcd)
^
Main.java:98: error: class, interface, or enum expected
else
^
Main.java:100: error: class, interface, or enum expected
}
^
Main.java:102: error: class, interface, or enum expected
if (curGcd == 1)
^
Main.java:104: error: class, interface, or enum expected
t = r;
^
Main.java:105: error: class, interface, or enum expected
}
^
Main.java:108: error: class, interface, or enum expected
}
^
Main.java:112: error: illegal character: '#'
#ifdef LOCAL
^
Main.java:114: error: class, interface, or enum expected
freopen ("output.txt", "w", stdout);
^
Main.java:115: error: illegal character: '#'
#endif
^
Main.java:116: error: class, interface, or enum expected
int T;
^
Main.java:117: error: class, interface, or enum expected
scanf("%d", &T);
^
Main.java:118: error: class, interface, or enum expected
for (int i = 0; i < T; i++)
^
Main.java:118: error: class, interface, or enum expected
for (int i = 0; i < T; i++)
^
Main.java:118: error: class, interface, or enum expected
for (int i = 0; i < T; i++)
^
Main.java:121: error: class, interface, or enum expected
solve();
^
Main.java:122: error: class, interface, or enum expected
}
^
Main.java:124: error: class, interface, or enum expected
}
^
76 errors