#include <iostream>
#include <list>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n,q,m,a;
    cin>>n>>q;
    vector<int> l(n);
    int p[q];
    for (int i = 0; i < n;i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    int br=0;
    for (int y = 0; y < q;y++){
        cin >> a;
        do {
            for (int j=0;j<=10;j++) {
                l[n]=j;
                if(n%2!=0){
                    m=l[(n-1)/2];
                }
                else {
                    m=(l[n/2]+l[(n-2)/2])/2;
                }   
                if (a==m){
                    br=-1;
                }
                if (m>a){
                    l[n]=10;
                }
                else {
                    l[n]=1;
                }
            }
            br+=1;
            
        } while (a!=m);
        p[y]=br;
        br=0;
    }
    for (int h=0;h<=q;h++){
        cout<<p[h]<<endl;
    }
    return 0;
}