#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}
int partition(int arr[], int low, int high)
{
    int pivot = arr[high]; // pivot
    int i = (low- 1);

    for (int j = low; j <= high - 1; j++)
    {
        if (arr[j] < pivot) {
            i++;
            swap(&arr[i], &arr[j]);
        }
    }
    swap(&arr[i + 1], &arr[high]);
    return (i + 1);
}

void quickSort(int arr[], int low, int high)
{
    if (low < high)
    {
        int pi = partition(arr, low, high);

        quickSort(arr, low, pi - 1);
        quickSort(arr, pi + 1, high);
    }
}
int calcMedian(int a[], int n)
{
    int k = n / 2;
    int answer = a[k];
    return answer;
}

int main()
{
    int n, m;
    cin >> n >> m;
    int votes[n];
    vector<int> values(m);
    vector<int> answer(m);
    for (int i = 0; i < n; i++)
    {
        cin >> votes[i];
    }

    quickSort(votes, 0, n - 1);
    for (int j = 0; j < m; j++)
    {
        cin >> values[j];
    }

    for (int j = 0; j < m; j++)
    {
        int t = values[j];
        if (t == calcMedian(votes, n))
        {
            answer[j] = 0;
        }
        else
        {
            int cN = 2147483647; // najmanja razdaljina
            int cNi = -1;
            for (int i = 0; i < n; i++)
            {
                if (abs(t - votes[i]) < cN) { cN = abs(t - votes[i]); cNi = i; }
            }
            if (votes[cNi] == t)
            {
                int minD = min(cNi, n - cNi - 1);
                int maxD = max(cNi, n - cNi - 1);
                if (n % 2 == 0)
                    answer[j] = maxD - minD;
                else answer[j] = maxD - minD - 1;
            }
            else
            {
                int ti;
                if (votes[cNi] < t) ti = cNi + 1;
                else ti = cNi - 1;
                int minD = min(ti, n - ti);
                int maxD = max(ti, n - ti );
                if (n % 2 == 0)
                    answer[j] = 1 + maxD - minD;
                else answer[j] = maxD - minD;
            }
        }
    }
    for (int i = 0; i < m; i++)
    {
        cout << answer[i] << "\n";
    }

    return 0;
}