#include<bits/stdc++.h>
using namespace std;
int n,q,br,br1,s,z,x;
int main(){
    cin>>n>>q;
    int a[n],b[q];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(int i=1;i<=q;i++){
        cin>>b[i];
        z=(n+1)/2;
        s=n;
        x=n;
        br=0;
        br1=0;
        for(int j=1;j<=n;j++){
            if(a[j]==b[i] and br==0){
                br=j;
                s=abs(z-br);
                if(s==0){
                    break;
                }
            }
            else if(a[j]==b[i] and br!=0){
                br1=j;
                x=abs(z-br1);
                if(x==0){
                    break;
                }
            }
        }
        if(abs(s)==0 or abs(x)==0){
            cout<<0<<endl;
        }
        else if(x==n){
            if(z>br){
                cout<<n-2*br+1<<endl;
            }
            else{
                cout<<2*br-n-2<<endl;
            }
        }
        else if(n%2==1){
            if(abs(s)<abs(x)){
                cout<<2*br-n-2<<endl;
            }
            else if(abs(s)>abs(x)){
                cout<<n-2*br1+1<<endl;
            }
        }
        else{
            if(abs(s)<abs(x)){
                cout<<2*br-n-3<<endl;
            }
            else if(abs(s)>abs(x)){
                cout<<n-2*br1<<endl;
            }
        }
    }
return 0;
}