53 - ZJUPC ZyXel Cup 2006 - 1002
Vivid has stored a piece of private information, which consisted of a serial of integers in a secret number format. All the stored numbers are in the range [-63, 63]. So every number contains exactly 7 bits - the leftmost bit is the sign bit (0 for positive and 1 for negative), and all other bits represent the absolute value of the number (e.g. 000000 stands for 0, 000001 stands for 1 and 111111 stands for 63). With the sign bit, 1000000 and 0000000 are considered to be equal, both of them stand for 0.
All the numbers have been pushed into 16-bits integers, that is, one 16-bits integer is enough to hold 2 numbers plus 2 bits of another number.
In this problem, you are given a serial of 16-bits integers, and you need to output the sum of these 7-bits integers.
There are multiple test cases. Each test case begins with an integer N (the number of 16-bits numbers, 0 <= N <= 7000, N is always a multiple of 7). Then N 16-bits numbers follow, all of which are in the range [0, 65535]. A case with N = -1 denotes the end of input, which should not be proceeded.
For each test case, output an integer indicating the sum of these 7bits-integers in a single line.Sample Input:
7 1 0 0 0 0 0 0 7 65535 65535 65535 65535 65535 65535 65535 -1Sample Output: