
In a city there is a tall skyscraper with
The skyscraper has one elevator that is large enough for all people to fit in, but it is so narrow that two people cannot stand side by side; they must be one behind the other.
Everybody got in the elevator, but they had not thought about the order in which
they have to exit it! Initially, the

The illustration above shows the starting order of people in the elevator in the first example. The elevator
is on floor
Mirko is viewing the situation they are in and contemplating. He wants to know how many exits from the elevator would there be if the people returning to the elevator always returned optimally. If a person exits the elevator multiple times, each time is counted separately.
Mirko is an experienced coder, and he can solve this problem quite easily. His happiness is short-lived,
because next to him is his friend Slavko. Slavko came up with
If the person at position
was not in the elevator, how many exits would there be then?
Mirko is interested in an answer before Slavko's first question and after every question. Note that for each question, all the people from previous questions are also not considered to be in the elevator. Mirko started solving the problem but soon realized that even for him, this would not be quite easy. Help him solve this problem!
Note: The elevator will always move from the first floor to the
Input Specificaton
The first line contains two non-negative integers
The second line contains
The third line contains
Output Specification
In one line, print
Constraints
Subtask | Points | Constraints |
---|---|---|
1 | 16 | |
2 | 19 | |
3 | 29 | |
4 | 46 | No additional constraints. |
Sample Input 1
5 2
3 4 1 2 5
3 2
Sample Output 1
9 6 4
Explanation for Sample 1

The illustration shows the exits from the elevator before the first query.
The elevator is on the first floor, and the person at position
After that, on the second floor, the person at position
After that, on the third floor, the person at position
After that, on the fourth floor, the person at position
And finally, on the fifth floor, the person at position
Sample Input 2
7 0
4 5 2 1 6 3 7
Sample Output 2
13
Sample Input 3
3 2
3 1 2
1 2
Sample Output 3
5 2 1
Comments