#include <bits/stdc++.h>
#define int long long
using namespace std;
int prvi(int a[], int l, int r, int b, int n)
{
    if (r >= l) {
        int mid=l+(r-l)/2;
        if((mid==0||b>a[mid-1])&&a[mid]==b)
            return mid;
        else if(b>a[mid])return prvi(a,(mid + 1),r,b,n);
        else return prvi(a,l, (mid - 1), b, n);
    }
    return 0;
}

int blizu(int, int, int);

int najblizi(int arr[], int n, int b)
{
    if (b <= arr[0])return arr[0];
    if (b >= arr[n - 1])return arr[n - 1];
    int i = 0, j = n, mid = 0;
    while (i < j) {
        mid = (i + j) / 2;
        if (arr[mid] == b)
            return arr[mid];
        if (b < arr[mid]) {
            if (mid>0 && b > arr[mid-1])
                return blizu(arr[mid-1],arr[mid], b);
                j=mid;
        }
        else {
            if (mid<n-1&&b<arr[mid+1])
                return blizu(arr[mid],arr[mid+1],b);
                i=mid+1;
        }
    }
    return arr[mid];
}


int blizu(int a, int c,int b){
    if (b-a>=c-b)return c;
    else return a;
}
signed main()
{
    int n,q;
    cin>>n>>q;
    map<int,int> m;
    int a[n];
    for(int i=0; i < n; i++){
        cin>>a[i];
        m[a[i]]=i;
    }
    sort(a,a+n);
    while(q--){
        int b;
        cin>>b;
         if(m.find(b)!=m.end()){
            int l=prvi(a,0,n-1,b,n);
            int r=m[b];
            //cout<<l<<" "<<r<<'\n';
            if(r==0)r=l;
            if(l==0)l=r;
            if(n/2>=l && n/2<=r){
                cout << 0 << '\n';
            }
            else{
                if(n/2>r){
                    if(n%2==0)cout<<2*(n/2-r)-1<<'\n';
                    else cout<< 2*(n/2-r)<<'\n';
                }
                else if(n/2<l){
                    if(n%2==0)cout<<2*(l-n/2)<<'\n';
                    else cout<<2*(l-n/2)-1<<'\n';
                }
            }
         }
         else{
              int ind1=najblizi(a,n,b);
              int ind=m[ind1];
              // cout<<"indeks"<<ind;

                int med=n/2;
              // cout<<med<<"\n";
                if(ind==med){
                    cout<<1<<'\n';
                }
                else{

                        if((n+1)%2==0)cout << 2*abs(ind-med)+1<<'\n';
                        else cout<< 2*(ind-med)<<'\n';

                }
            }
         }
    }