#include <bits/stdc++.h>

// pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
// gp_hash_table<int, int> table;

using namespace std;

#define vec vector
#define ALL(x) begin(x), end(x)

typedef unsigned long long ull;
typedef unsigned int ui;
typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;

const int inf = 1000 * 1000 * 1000;
const ll inf64 = 1e18;

const int N = 1e5 + 5;

int n, q;
int a[N];

ll slow(int x) {
    vector< int > used(n + 1);
    ll res = 0;
    for(int iter = 1;iter <= n;iter++) {
        if(iter & 1) {
            int i = n;
            while(used[i]) i--;
            res += a[i];
            used[i] = 1;
        }else {
            int p = -1;
            for(int i = 1;i <= n;i++) {
                if(used[i]) continue;
                if(p == -1 || abs(a[i] - x) < abs(a[p] - x)) p = i;
            }
            used[p] = 1;
        }
    }
    return res;
}

ll pref[N][2];

ll get_sum(int l, int r) {
    if(l > r) return 0;
    return pref[r][0] + pref[r][1] - pref[l - 1][0] - pref[l - 1][1];
}

void build() {
    for(int i = 1;i <= n;i++) {
        pref[i][0] = pref[i - 1][0];
        pref[i][1] = pref[i - 1][1];
        pref[i][i & 1] += a[i];
    }
}

int count_leq(int x, int max_dist) {
    // |a[i] - x| <= max_dist
    // -max_dist <= a[i] - x <= max_dist
    // -max_dist + x <= a[i] <= max_dist + x
    return upper_bound(a + 1, a + n + 1, max_dist + x) - lower_bound(a + 1, a + n + 1, -max_dist + x) - 1;
}

ll fast(int x) {
    ll res = 0;
    int bl = 0;
    int br = n;
    int bm;
    while(br - bl > 1) {
        bm = (bl + br) / 2;
        if(count_leq(x, abs(a[bm] - x)) >= n - bm + 1) {
            br = bm;
        }else {
            bl = bm;
        }
    }
    int p = count_leq(x, abs(a[br] - x)) >= n - br + 1 ? br : br + 1;
    res += get_sum(p, n);
    if(p > n) {
        return pref[n][n & 1] + res;
    }
    int cnt = count_leq(x, abs(a[p] - x));
    if(cnt == n - p + 1) {
        int i = n - cnt - (n - p + 1);
        return res + pref[i][i & 1];
    }else {
        if(count_leq(x, abs(a[p - 1] - x)) >= n - p + 1) {
            res += a[p - 1];
            cnt = n - p + 1;
            p--;
            int i = n - cnt - (n - p + 1);
            return pref[i][1 ^ (i & 1)] + res;
        }else {
            cnt = n - p + 1;
            int i = n - 2 * cnt;
            return pref[i][i & 1] + res;
        }
    }
}

int get_rnd(mt19937 &rnd, int l, int r) {
    int ln = r - l + 1;
    return rnd() % ln + l;
}

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

//#define TEST

#ifndef TEST
    cin >> n >> q;
#else
    n = 50;
    q = 100;
#endif

    mt19937 rnd(time(NULL));

    for(int i = 1;i <= n;i++) {
#ifndef TEST
        cin >> a[i];
#else
        a[i] = get_rnd(rnd, a[i - 1] + 1, a[i - 1] + 10);
#endif
    }

    build();

    for(int iter = 0;iter < q;iter++) {
        int x;
#ifndef TEST
        cin >> x;
        cout << fast(x) << "\n";
//        cout << slow(x) << "\n";
#else
        x = get_rnd(rnd, *min_element(a, a + n + 1), *max_element(a, a + n + 1));
        ll fs = fast(x);
        ll sl = slow(x);
        if(fs != sl) {
            cout << "#" << iter + 1 << "\n";
            cout << "WA!\n";
            cout << n << "\n";
            for(int i = 1;i <= n;i++) {
                cout << a[i] << " ";
            }
            cout << "\n";
            cout << "x = " << x << "\n";
            cout << "expected = " << sl << "\n";
            cout << "found = " << fs << "\n";
            return 0;
        }else {
            cout << " OK \n";
        }
#endif
    }

    return 0;
}


Measured memory_bytes: 3712