#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll t,n,a[3123456],tot=0;
void pre(){
ll temp=(1ll<<31);
for(ll i=1;(1+i)*i/2<=temp;i++){
a[++tot]=(1+i)*i/2;
// cout<<a[i]<<endl;
}
}
int main(){
cin>>t;
pre();
while(t--){
scanf("%lld",&n);
ll gk=lower_bound(a+1,a+1+tot,n)-a;
cout<<n-a[gk-1]<<endl;
}
}