#include<stdio.h>
#include<vector>
#include<algorithm>
#include<iostream>
typedef long long ll;
int main()
{
using namespace std;
vector<ll> ar;
using namespace std;
ll t,i,k;
ar.push_back(0);
for(i=1;i<=500000;i++)
{
k=ar[i-1]-i;
if((ar[i-1]-i)>0 && find(ar.begin(),ar.end(),k)==ar.end())
ar.push_back(ar[i-1]-i);
else
ar.push_back(ar[i-1]+i);
}
while(scanf("%lld",&t)==1)
{
if(t==-1)
break;
printf("%lld\n",ar[t]);
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8dmVjdG9yPgojaW5jbHVkZTxhbGdvcml0aG0+CiNpbmNsdWRlPGlvc3RyZWFtPgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKaW50IG1haW4oKQp7Cgl1c2luZyBuYW1lc3BhY2Ugc3RkOwoJdmVjdG9yPGxsPiBhcjsKCXVzaW5nIG5hbWVzcGFjZSBzdGQ7CglsbCB0LGksazsKCWFyLnB1c2hfYmFjaygwKTsKCWZvcihpPTE7aTw9NTAwMDAwO2krKykKCQl7CgkJCWs9YXJbaS0xXS1pOwoJCQlpZigoYXJbaS0xXS1pKT4wICYmIGZpbmQoYXIuYmVnaW4oKSxhci5lbmQoKSxrKT09YXIuZW5kKCkpCgkJCQlhci5wdXNoX2JhY2soYXJbaS0xXS1pKTsKCQkJCWVsc2UKCQkJCWFyLnB1c2hfYmFjayhhcltpLTFdK2kpOwoJCX0KCXdoaWxlKHNjYW5mKCIlbGxkIiwmdCk9PTEpCgl7CgkJaWYodD09LTEpCgkJYnJlYWs7CgkJcHJpbnRmKCIlbGxkXG4iLGFyW3RdKTsKCX0KCXJldHVybiAwOwp9