#include<bits/stdc++.h>
using namespace std;
// #DynamicProgramming #Placement
int minSteps(int d);
int solve(int s, int d, int i, int steps, map< pair<int,int> , int > &memo);
int main(){
int t;
cin>>t;
while(t--){
int d;
cin>>d;
cout<< minSteps(d) <<endl;
}
return 0;
}
int minSteps(int d){
map< pair<int,int> , int > memo;
return solve(0,d,1,0,memo);
}
int solve(int s, int d, int i, int steps, map < pair<int,int> , int > &memo){
if(s==d){
memo[{s,d}]=0;
return steps+memo[{s,d}];
}
if(memo[{s,d}]!=0){
return memo[{s,d}];
}
int right=solve(s+i,d,i+1,steps+1,memo);
int left=solve(s-i,d,i+1,steps+1,memo);
if(left!=-1 && right!=-1){
memo[{s,d}]=min(left,right);
return memo[{s,d}];
}
if(left!=-1){
memo[{s,d}]=left;
return memo[{s,d}];
}
if(right!=-1){
memo[{s,d}]=right;
return memo[{s,d}];
}
return -1;
}