#include <bits/stdc++.h>
#define wibu(i,a,b) for (i=a;i<b;i++)
#define amane(i,a,b) for (i=a;i<=b;i++)
#define mahiru(i,a,b) for (i=a;i>=b;i--)
#define hoang10 int main
#define name "SUBSEQ"
#define f first
#define s second
#define pb push_back
#define p push
#define TIME (1.0*clock()/CLOCKS_PER_SEC)
using namespace std;
int gl[1000005], gr[1000005], a[1000005];
int n;
bool check(int k)
{
	for (int i = 0; i < n; i++)
	{
		if (i == 0 || i % k == 0)
			gl[i] = a[i];
		else
			gl[i] = __gcd(gl[i - 1], a[i]);
	}

	for (int i = n - 1; i >= 0; i--)
	{
		if (i == n - 1 || i % k == 0)
			gr[i] = a[i];
		else
			gr[i] = __gcd(gr[i + 1], a[i]);
//		cout << gr[i] << ' ';
	}
//	cout << '\n' << k << '\n';

	for (int i = 0; i + k - 1 < n; i++)
	{
		if (__gcd(gr[i], gl[i + k - 1]) != 1)
			return true;
	}
	return false;
}
hoang10()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	if(fopen(name".INP","r"))
	{
		freopen (name".INP","r",stdin);
		freopen (name".OUT","w",stdout);
	}
	int nhap;
	cin >> nhap;
	while (nhap--)
	{
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
			a[i] = abs(a[i]);
		}

		int l = 1, r = n, ans = 0;
		while (l <= r)
		{
			int mid = (l + r) / 2;
			if (check(mid))
			{
				ans = mid;
				l = mid + 1;
			}
			else
				r = mid - 1;
		}
		cout << ans << '\n';
	}

return 0;
}
