{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"The Recaman\u0027s sequence is defined by a0 \u003d 0 ; for m \u0026gt; 0, a\u003csub\u003em\u003c/sub\u003e \u003d a\u003csub\u003em−1\u003c/sub\u003e − m if the rsulting a\u003csub\u003em\u003c/sub\u003e is positive and not already in the sequence, otherwise a\u003csub\u003em\u003c/sub\u003e \u003d a\u003csub\u003em−1\u003c/sub\u003e + m.\r\u003cbr\u003eThe first few numbers in the Recaman\u0027s Sequence is 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9 ...\r\u003cbr\u003eGiven k, your task is to calculate a\u003csub\u003ek\u003c/sub\u003e."}},{"title":"Input","value":{"format":"HTML","content":"The input consists of several test cases. Each line of the input contains an integer k where 0 \u0026lt;\u003d k \u0026lt;\u003d 500000.\r\u003cbr\u003eThe last line contains an integer −1, which should not be processed."}},{"title":"Output","value":{"format":"HTML","content":"For each k given in the input, print one line containing a\u003csub\u003ek\u003c/sub\u003e to the output."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e7\r\n10000\r\n-1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e20\r\n18658\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}