#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;
void init(int*data,bool*visit){
    int t = 0;
    data[0] = 0;
    for(int i=1;i<=500000;i++){
        if(t-i>0&&!visit[t-i]){
            t = t-i;
        }
        else{
            t = t+i;
        }
        visit[t] = 1;
        data[i] = t;
    }
}
int main(){
    int*data = new int[500005];
    bool*visit = new bool[10000000];
    memset(visit,0,sizeof visit);
    init(data,visit);
    int n;
    while(scanf("%d",&n)==1&&n!=-1){
        printf("%d\n",data[n]);
    }
    return 0;
}