#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);

    ll N, Q, i, j, q, t, k=0;
    bool found;
    cin >> N >> Q;
    ll a[10000], b[10000], najjace[10000];
    for(i=0;i<N;++i) {
        cin >> a[i];
    }
    for(i=0;i<Q;++i){
        cin >> b[i];
    }
    vector<ll> v;
    t = N/2;
    for(j=0;j<Q;++j)
    {
        q = b[j];
        found = false;
        for(i=0;i<N;++i)
        {
            if(a[i]==q && !found)
            {
                ans = abs(i-t);
                found = true;
            }
        }
        if(!found)
            ans = N;
        najjace[k++] = ans;
    }
    for(i=0;i<Q;++i)
    {
        if(i==Q-1) {
            cout << najjace[i];
            return 0;
        }
        cout << najjace[i] << endl;
    }
    return 0;
}