#include<stdio.h>
#include<stdlib.h>
void unos(int n, int a[n])
{
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
}
void sort(int n, int a[n])
{
    int temp = 0;
    for(int i = 0; i < n-1; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            if(a[i]>a[j])
            {
                temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
    }
}
int vracaUniz(int n, int a[n], int k)
{
    int br = 0;
    for(int i = 0; i < n; i++)
    {
        if(a[i] == k)
        {
            br++;
        }

    }
    return br;
}
void stampa(int n, int a[n])
{
    for(int i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
    printf("\n");
}

int median(int n, int a[n], int k)
{
    int provera = vracaUniz(n, a, k);
    if(provera > 0)
    {
    int zin[provera];
    int pozk = 0;
    int niz[n];
    int z = 1;
    //stampa(n, a);
    for(int i = 0; i<n; i++)
    {
        if(a[i] == k)
        {
            pozk = i;

        }
    }
    int v = 2;
    if(n%2 == 1)
    {
        niz[n/2] = 0;
        while((n/2-z) > -1)
        {
            niz[n/2-z] = 2 * z;
            z++;
        }
        niz[n/2+1] = 1;
        while ((n/2+v)<n)
        {
            niz[n/2+v] = 1 + (v-1) * 2;
            v++;
        }
        int l = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[i] == k){
            zin[l] = niz[i];
            l++;}
        }
        sort(provera, zin);
        return zin[0];
        
    }
    else
    {
        z = 2;
        v = 1;
        niz[n/2] = 0;
        niz[n/2-1] = 1;
        while((n/2-z)>-1)
        {
            niz[n/2-z] = niz[n/2-z+1] + 2;
            z++;
        }
        while((n/2+v) < n)
        {
            niz[n/2+v] = niz[n/2+v-1] + 2;
            v++;
        }
        for(int i = 0; i < n; i++)
        {
            if(a[i] == k)
            return niz[i];
        }
    }
    }
    else
    {
    int b[n + 1];
    for(int i = 0; i < n; i++)
    {
         b[i] = a[i];
    }
    b[n] = k;
    n = n+1;
    sort(n, b);
    int pozk = 0;
    int niz[n];
    int z = 1;
    //stampa(n, b);
    for(int i = 0; i<n; i++)
    {
        if(b[i] == k)
        {
            pozk = i;

        }
    }
    int v = 2;
    if(n%2 == 1)
    {
        niz[n/2] = 0;
        while((n/2-z) > -1)
        {
            niz[n/2-z] = 2 * z;
            z++;
        }
        niz[n/2+1] = 1;
        while ((n/2+v)<n)
        {
            niz[n/2+v] = 1 + (v-1) * 2;
            v++;
        }
        for(int i = 0; i < n; i++)
        {
            if(b[i] == k)
            return niz[i]+1;
        }
        
    }
    else
    {

        z = 2;
        v = 1;
        niz[n/2] = 0;
        niz[n/2-1] = 1;
        while((n/2-z)>-1)
        {
            niz[n/2-z] = niz[n/2-z+1] + 2;
            z++;
        }
        while((n/2+v) < n)
        {
            niz[n/2+v] = niz[n/2+v-1] + 2;
            v++;
        }
        for(int i = 0; i < n; i++)
        {
            if(b[i] == k)
            return niz[i]+1;
        }
    }
    }
}
int main()
{
    int n, q, daLi;
    scanf("%d%d", &n, &q);
    int a[n], b[q];
    unos(n, a);
    unos(q, b);
    //stampa(n, a);
    sort(n,a);
    //stampa(n,a);
    //stampa(q,b);
    for(int i = 0; i < q; i++)
    printf("%d\n", median(n, a, b[i]));

}