#define _USE_MATH_DEFINES
#include<iostream>
#include<sstream> 
#include<cmath>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<conio.h>
#include<numeric>
#include<map>
#include<set>
#include<stack>
#include<stdlib.h>  
#include<unordered_map>
#include <queue>
using namespace std;

#define int long long

void printvector(vector<int>a) {
    for (int i = 0; i < a.size(); i++) cout << a[i] << " ";
    cout << endl;
}
int bruteforce(vector<int>a, int n, int target, int ind) { // target = b[i]
    int ans = 0;
    while (target != a[n / 2]) {
        a.insert(a.begin() + ind, target);
        n++;
        ans++;
    }
    return ans;
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int>a(n);
    vector<int>b(q);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < q; i++) cin >> b[i];
    //cout << a[n / 2] << endl;
    int ans = 0;int ind;

    for (int i = 0; i < q; i++) {
        ans = 0;
        int br_elem_desno = 0;
        int br_elem_levo = 0;
        //ako element ne postoji doda ga u vector
        if (!binary_search(a.begin(), a.end(), b[i])) {
            auto it = lower_bound(a.begin(), a.end(), b[i]);
            if (it == a.end()) ind = n;
            else ind = it - a.begin();
            a.insert(a.begin() + ind, b[i]);
            n++;
            ans++;
        }
        //ako ga je vec pronaslo
        if (a[((n / 2))] == b[i]) {
            cout << ans << '\n';
            continue;
        }
        else {
            auto it = lower_bound(a.begin(), a.end(), b[i]);
            ind = it - a.begin();
            if (ind < n / 2) {
                //ako se element nalazi levo od trenutnog medijana
                //povecavamo dok leva strana nije jednaka desnoj
                br_elem_levo = br_elem_levo + ind;
                br_elem_desno = br_elem_desno + n - ind - 1;
                //cout << "br. elem. levo: " << br_elem_levo << " br. elem. desno: " << br_elem_desno << endl;
                ans = ans+abs(br_elem_levo - br_elem_desno);
                cout << ans << endl;
            }
            else {
                //ako se element nalazi desno on trenutnog medijana
                //povecavamo sve dok leva strana nije za 1 veca od desne
                br_elem_levo = br_elem_levo + ind;
                br_elem_desno = br_elem_desno + n - ind - 1;
                //cout << "br. elem. levo: " << br_elem_levo << " br. elem. desno: " << br_elem_desno << endl;
                ans = ans+abs(br_elem_levo - br_elem_desno - 1);
                cout << ans << endl;
            }
        }
    }
    return 0;
}