P13270 [CodeChef] cdva1604
NOI
题目描述

Everyone knows the famous detective Sherlock. He has been handed over a new case of "The Abominable Bride". Each night she kills N people but to irritate
Sherlock she leaves exactly one people. The way she kills the people is somewhat strange. She makes 1 to N people stand in a line and starts killing
them. But, in the line when she kills the first person, there's time for the person standing next in line to run away at the end of the line.Again she kills the first
person and the second one next to him runs to the last of the line. In this way after killing, there is exactly one person standing in the line who is saved and he
runs to Sherlock to explain the situation each night. Help Sherlock find out the person that will be saved at the end of the massacre.

Constraints and Example
Input:
5
2
4
6
9
12

Output:
2
4
4
2
8

Explanation

For the 2nd test case, she kills 1 and 2 goes at the end of line i.e., 3 4 2. Then she kills 3rd and 4th goes at the end of line i.e. 2 4. Then she kills 2 and
ultimately 4th is the lone survivour.

输入格式

见题面

输出格式

见题面

样例输入
5 2 4 6 9 12
样例输出
2 4 4 2 8