Sign Moves

 Initially, Chef is at coordinate 

on X-axis. For each

in order, Chef does the following:

  • If Chef is at a non-negative coordinate, he moves
steps backward (i.e, his position's coordinate decreases by ), otherwise he moves steps forward (i.e, his position's coordinate increases by
  • ).

You are given the integer

. Find the final position of Chef on the X-axis after

operations.

Input Format

  • The first line of input contains an integer
, denoting the number of test cases. The
  • test cases then follow:
  • The first and only line of each test case contains an integer
    • .

    Output Format

    For each test case, output in a single line the final position of Chef on the X-axis after

    operations.

    Constraints

    Sample Input 1

    3
    1
    2
    3
    

    Sample Output 1

    -1
    1
    -2
    

    Explanation

    Test case

    : Initially, Chef is at coordinate on X-axis. As is non-negative, during the first operation Chef moves step backward and reaches the coordinate

    .

    Test case

    : Chef is at coordinate on X-axis after the first operation. As is negative, during the second operation Chef moves steps forward and reaches the coordinate .
    Previous
    Next Post »