#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main() {
    int n;
    int q;
    int med;
    int t;
    int ind;
    cin >> n;
    cin >> q;


    vector<int> a;
    vector<int> b;
    for (int k = 0;k<n;k++){
        int num;
        cin >> num;
        a.push_back(num);
    }
    for (int k = 0;k<q;k++){
        int num;
        cin >> num;
        b.push_back(num);
    }
    if (n % 2 == 1){
        med = a.at(floor(n/2));
        t =  (floor(n/2));
    }else{
        med = a.at((n/2));
        t =  (floor(n/2));
    }
    for (int i = 0; i < q;i++){
        if (b.at(i) == med){
            cout << 0 << endl;
        }
        else{
            for (int j = 0;j<n;j++){
                if (a.at(j) == b.at(i)){
                    ind = j;

                }
            }
            cout << ind - t << endl;
        }
    }


}