#include<bits/stdc++.h>
using namespace std;
using ll=long long;
// special case 1009
// Cmax = floor((B^2)/2)+1;
void solve2()
{
ll B,h,H,sqH,ans,hh,BB; cin>>B;
BB = B*B;
for(ll h=1;h<=10000000;h++)
{
hh = h*h;
H = BB+hh;
sqH = sqrt(H);
if(sqH*sqH==H)
{
cout<<"base = "<<B<<endl;
cout<<"hight= "<<h<<endl;
cout<<"hypo = "<<sqH<<endl;
cout<<endl;
}
}
}
//ofstream file("output0.txt");
void solve()
{
ll B,h,H,sqH,ans,hh,sqB; cin>>B;
sqB = B*B;
ll limit = (sqB/2)+5;
ans=-1;
// for(ll h=limit;h>=1;h--)
for(ll h=1000000;h>=1;h--) //timeout
{
sqH = sqB+h*h;
H = sqrt(sqH);
if(H*H==sqH)
{
ans=H+B+h;
break;
}
}
cout<<ans<<endl;
//file<<ans<<endl;
}
int main()
{
int t; cin>>t; while(t--) solve();
// file.close();
}