#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
// trebalo bi da prodje tle, mzd ima neko bolje resenje though
ll ans;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    vector<int> v;
    vector<int> ::iterator it;
    int n, q;
    int pos, i, x;
    cin >> n >> q;
    int t = n, mid = n/2;
    int b[10000];
    for(i=0;i<n;++i) {
        cin >> x;
        v.push_back(x);
    }
    for(i=0;i<q;++i) {
        cin >> b[i];
    }

    for(i=0;i<q;++i)
    {
        ans=0;
        n = t;
        it = find(v.begin(), v.end(), b[i]);
        if(it!=v.end())
        {
            pos = it - v.begin();
            while(n/2!=pos)
            {
                if(pos>mid)
                {
                    n++;
                    ans++;
                }
                else if(pos<mid)
                {
                    n--;
                    ans++;
                }
            }
        }
        else
        {
            ans = n;
        }
        cout << ans << endl;
    }
    return 0;
}