This page is still under construction.

Parts of this page are still being built. What you see may change.

Conductors

Time limit1sMemory limit128 MB

Summary
Conductors with different speeds start at their own compartments and take the smallest unchecked one when free, and the goal is the last compartment of each.
Level

Hard8 of 10

Topics
Binary search, Math, Sorting
Solved
No attempts yet

Problem

Bajtazar works as a conductor for Byteotian State Railways (BKP), famous for the longest passenger trains in all of Byteotia. Special trains call for special procedures, so the BKP board introduced rules to streamline the conductors' work. Among other things, ticket inspection proceeds as follows:

  • At the start, all nn compartments in the train are numbered from 11 to nn. Likewise, each of the kk conductors is given a unique identifier, a number from 11 to kk.
  • Each conductor then begins checking tickets in the compartment whose number equals their identifier.
  • A conductor who finishes checking their compartment moves on to the compartment with the smallest number among those not yet checked. If two conductors finish at the same moment, the one with the smaller identifier goes first.
  • If a conductor finishes a compartment and no compartments are left to check, their work is done.
  • Inspection of the train ends once tickets in every compartment have been checked.

For economic reasons, the number of conductors never exceeds the number of compartments.

Every compartment in a BKP train is identical, so the time to check a single compartment depends only on the conductor's speed. Moreover, BKP values individuality, so no two conductors take the same amount of time to check a compartment.

Afterward, Bajtazar's colleagues always brag about who checked the higher-numbered compartment. Help Bajtazar find out whether he has anything to brag about: write a program that, for each conductor, determines the number of the last compartment in which they checked tickets.

Input

The first line contains two integers nn and kk (1≤n≤2⋅10131 \le n \le 2 \cdot 10^{13}, 1≤k≤1000001 \le k \le 100000, k≤nk \le n), the number of compartments and the number of conductors, respectively.

The second line contains kk pairwise distinct integers a1,…,aka_1, \dots, a_k. The value aia_i (1≤ai≤1051 \le a_i \le 10^5) is the time conductor ii needs to check a single compartment.

Output

On the first line, print kk integers: the numbers of the last compartments the conductors check, in order of increasing identifier.

Note

The picture above shows how an inspection unfolds. Columns correspond to consecutive time units, rows to conductors, and the bold numbers to the compartment each conductor occupies at that moment.

Examples2

  1. Example 1

    Input
    10 3
    3 5 6
    
    Expected output
    10 9 7
    
  2. Example 2

    Input
    8 3
    2 3 4
    
    Expected output
    8 5 7