program stairs;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
a,b,c,i: integer;
begin
assign(input,'stairs.in');reset(input);
read (c);
for i:=1 to c do begin
read (a);
b:=0;
while a-(b+1) > 0 do begin
  a := a - (b+1);
  b := b + 1;
end;
write (a);
writeln;
end;

  { TODO -oUser -cConsole Main : Insert code here }
end.
