#include <bits/stdc++.h>

using namespace std;

int main()
{


    int a,b;
    vector <int> g1;
    vector <int> g2;
    cin >> a >>b;
    for (int i =0;i<a;i++){
        int k;
        cin >>k;
        g1.push_back(k);
    }
    sort(g1.begin(),g1.end());
    for(int i = 0;i<b;i++){
        int k;
        cin>>k;
        g2.push_back(k);


    }
    for(int i = 0;i<b;i++){
        if(find(g1.begin(),g1.end(),g2.at(i)) != g1.end()){
                            sort(g1.begin(),g1.end());

            int pos = find(g1.begin(),g1.end(), g2.at(i)) -g1.begin()+1;
            if(pos > floor(g1.size()/2)  +1){
                cout<<(pos-1)*2 -g1.size()<<endl;
            }
            else if(pos <floor(g1.size()/2)  +1){
                cout<<(g1.size()-pos)*2-g1.size()+1<<endl;
            }
            else{
                cout<<"0"<<endl;
            }
        }
        else{
            vector<int> g3 = g1;
            g3.push_back(g2.at(i));
            sort(g3.begin(),g3.end());
            int pos = find(g3.begin(),g3.end(), g2.at(i)) -g3.begin()+1;
            if(pos > floor(g3.size()/2) +1){
                cout<<(pos-1)*2 -g3.size()+1<<endl;
            }
            else if(pos <floor(g3.size()/2)  +1){
                cout<<(g3.size()-pos)*2-g3.size()+2<<endl;
            }
            else{
                cout<<"0"<<endl;
            }

        }
    }


    return 0;
}