Counting-Out#7332

Counting-Out

3 seconds
64 megabytes
Medium

children, standing in a circle, are using counting-outs to determine who will leave the circle. It means, they recite counting-out rhymes, pointing at the next (in the circle) child with each word. The child pointed to at the last word of the rhyme leaves the circle.

The process repeats (1 \le k \le n) times, restarting from the child following the one who just left the circle. Counting starts from lower numbers to higher, but counting-out rhymes are different.

Write a program which reads number of children, number of counting-out rhymes, and numbers of words in used counting-out rhymes, and finds the order in which children will leave the circle.

Input

The first line contains space separated number of children (1 \le n \le 10^{18}) and number of used counting-out rhymes (1 \le k \le \min(n, 10^5)). The second line contains integers (each in range 1 \le a_i \le 10^{18}) - numbers of words in the counting-out rhymes, used the st, the nd, …, the -th time.

Output

The only line of the output should contain a space-separated sequence of numbers - the numbers of the children leaving the circle after the corresponding counting-out. Initially, children are numbered from to , and the st is the child who is pointed on when reciting the st word of the st counting-out rhyme. Further, each child keeps the same number, irrespectively of how children leave the circle.

Examples

Example 1

Loading
Loading

Example 4

Loading
Loading