#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 500001
bool mark[10 * N];
int a[N];
int main()
{
memset(mark, 0, sizeof(mark));
a[0] = 0;
for(int i = 1; i < N; i++)
{
int t = a[i - 1] - i;
if(t > 0 && !mark[t]) a[i] = t;
else a[i] = a[i - 1] + i;
mark[a[i]] = 1;
}
int k;
while(scanf("%d", &k), k != -1)
{
printf("%d\n", a[k]);
}
return 0;
}