#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define trace(x) cerr << #x << ": " << x << '\n'
int sum(int n)
{
return (n * (n + 1)) / 2;
}
int divcnt(int n)
{
int cnt = 0;
for (int i = 1; i <= sqrt(n); i++)
{
if (n % i == 0)
{
cnt++;
if (i != n / i)
cnt++;
}
}
return cnt;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// int mx = 0;
// for (int i = 1; i <= 100; i++)
// {
// int s = sum(i);
// mx = max(mx, divcnt(s));
// cout << i << " " << mx << endl;
// }
int t;
cin >> t;
while (t--)
{
int n, mx = 0, ans = 0;
cin >> n;
for (int j = n, i = 0; i < 10 and j >= 0; j--, i++)
{
int s = sum(j);
int cnt = divcnt(s);
if (cnt > mx)
{
mx = cnt;
ans = j;
}
}
cout << ans << '\n';
}
return 0;
}