M. Memory Manager
time limit per test
1.5 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

Memory managers are parts of operating systems and programming systems that manage memory allocation, deallocation, and optimize memory resources for processes. The lowest level of managers operates with pages of physical memory – fix-sized blocks of the same length, into which the entire available address space is divided.

Page managers must work very quickly and implement extremely simple algorithms. Develop a simple page manager that works according to the following rules:

  1. Initially, a manager has $$$n$$$ free pages, numbered from $$$0$$$ to $$$n - 1$$$.
  2. A manager can select pages only one at a time. Once a page is selected, it becomes occupied and cannot be selected again.
  3. Each $$$i$$$th allocation request specifies a preferred page number $$$h_i$$$ – the page that the requester would like to obtain.
  4. If the preferred page with the number $$$h_i$$$ is available, then the manager allocates it.
  5. If the preferred page is occupied, then the nearest free one is allocated $$$r_i$$$, with a minimum difference of $$$|r_i - h_i|$$$. If there are 2 such pages, then the page with the lower number $$$r_i$$$ is selected.
  6. After selecting the page, the manager marks it as occupied and returns its number $$$r_i$$$ as a response to the request.
  7. It is assumed that the manager has enough free pages to satisfy all incoming requests.
Input

The first line contains two numbers $$$n$$$ $$$(0 \lt n \le 10^5)$$$ and $$$k$$$ $$$(0 \lt k \le 10^5, k \le n)$$$ separated by a space. This is followed by $$$k$$$ lines, each describing a request. Each request consists of a single number $$$h_i$$$ $$$(0 \le h_i \lt n)$$$ – the number of the preferred page.

Output

Print $$$k$$$ lines, each containing a single integer $$$r_i$$$ $$$(0 \le r_i \lt n)$$$ – the number of the page allocated in response to the request $$$h_i$$$.

Examples
Input
5 3
0
2
4
Output
0
2
4
Input
5 3
2
2
2
Output
2
1
3