#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <stack>
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ll long long
#define ull unsigned long long
#define uint unsigned int
using namespace std;
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <stack>
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ll long long
#define ull unsigned long long
#define uint unsigned int
using namespace std;
int n,temp;
int v[5111111];
int a[511111];
int main() {
a[0] = 0;
memset(v, 0, sizeof(v));
for (int i = 1; i <= 500000; i++) {
a[i] = a[i - 1] - i;
if (a[i] <= 0 || v[a[i]] != 0)
a[i] = a[i - 1] + i;
v[a[i]] = 1;
}
while (scanf("%d", &n), n != -1)
printf("%d\n", a[n]);
return 0;
}