#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) cin >> A[i];
int maxBlock = 1;
for (int len = 2; len <= N; ++len) {
if (N % len != 0) continue;
int blockCount = N / len;
bool possible = false;
// Try all combinations of dividing into blocks of size len
vector<int> temp = A;
sort(temp.begin(), temp.end());
do {
bool ok = true;
int diff = -1;
for (int i = 0; i < N; i += len) {
int mx = *max_element(temp.begin() + i, temp.begin() + i + len);
int mn = *min_element(temp.begin() + i, temp.begin() + i + len);
if (diff == -1)
diff = mx - mn;
else if (mx - mn != diff) {
ok = false;
break;
}
}
if (ok) {
possible = true;
break;
}
} while (next_permutation(temp.begin(), temp.end()));
if (possible) maxBlock = max(maxBlock, blockCount);
}
cout << maxBlock << '\n';
}
return 0;
}