#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
bool check(vector<int>& A, int start, int diff) {
int minVal = A[start], maxVal = A[start];
for (int i = start; i < A.size(); i += diff) {
minVal = min(minVal, A[i]);
maxVal = max(maxVal, A[i]);
if (maxVal - minVal != diff) {
return false;
}
}
return true;
}
int maxPartitions(vector<int>& A) {
int n = A.size();
int maxPartitions = 1;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
int diff = n / i;
if (check(A, 0, diff)) {
maxPartitions = max(maxPartitions, i);
}
}
}
return maxPartitions;
}
int main() {
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
A[i] = i + 1;
}
cout << maxPartitions(A) << endl;
}
return 0;
}