Under construction

Still being built. Things may change

kex

Interview

Time limit2sMemory limit1024 MB

Summary
Given a set A and several values k, find for each k the k-th smallest non-negative integer that is not in A.
Level

Medium4 of 10

Topics
Binary search, Sorting, Array
Solved
No attempts yet

Statement

Consider the set of non-negative integers AA. The minimum non-negative integer that does not occur in this set is denoted mex(A)\mathrm{mex}(A). For example, mex({0,1,2,4,5,9})=3\mathrm{mex}(\{0, 1, 2, 4, 5, 9\})=3.

Ann generalizes the concept of mex. For a positive integer kk and a set of non-negative integers AA, kex(A,k)\mathrm{kex}(A,k) is the kk-th smallest integer that is not in AA. For example, kex({0,1,2,4,5,9},2)=6\mathrm{kex}(\{0, 1, 2, 4, 5, 9\}, 2)=6.

For the given set AA and qq values kik_i, find kex(A,ki)\mathrm{kex}(A, k_i) for each ii.

Input

The first line contains two integers nn and qq (1≤n,q≤1051 \leq n, q \leq 10^5), the number of elements in AA and the number of kex values to find.

The second line contains nn distinct non-negative integers, each at most 10910^9. These are the elements of AA.

The third line contains qq integers kik_i (1≤ki≤1091 \leq k_i \leq 10^9).

Output

Print kex(A,k1),kex(A,k2),…,kex(A,kq)\mathrm{kex}(A, k_1), \mathrm{kex}(A, k_2), \ldots, \mathrm{kex}(A, k_q).

Examples1

  1. Example 1

    Input
    4 10
    1 2 6 7
    1 2 3 4 5 6 7 8 10 11
    
    Expected output
    0 3 4 5 8 9 10 11 13 14