"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function main(input) {
  var lines = input.split('\n');

  var _splitNum = splitNum(lines[0]),
      _splitNum2 = _slicedToArray(_splitNum, 2),
      N = _splitNum2[0],
      Q = _splitNum2[1];

  var A = splitNum(lines[1]).slice(0, N);
  var X = splitNum(lines.slice(2)).slice(0, Q);
  var cards = A.map(function (a, idx) {
    return {
      value: a,
      idx
    };
  }); // ranking by Takahashi

  cards.sort(function (x, y) {
    return y.value - x.value;
  });
  var _iteratorNormalCompletion = true;
  var _didIteratorError = false;
  var _iteratorError = undefined;

  try {
    var _loop = function _loop() {
      var x = _step.value;
      var taken = new Array(N).fill(false); // sort A by Aoki preference.

      var cvp = function cvp(card) {
        return Math.abs(card.value - x) + (card.value < x ? -0.1 : 0);
      };

      var mycards = cards.concat([]).sort(function (x, y) {
        return cvp(x) - cvp(y);
      }); // simulate the game.

      var sum = 0;
      var takahashi = 0;

      for (var i = 0; i < N; i++) {
        // Takahashi takes one
        for (; takahashi < N; takahashi++) {
          var c = cards[takahashi];

          if (!taken[c.idx]) {
            taken[c.idx] = true;
            sum += c.value;
            takahashi++;
            break;
          }
        }

        for (; i < N; i++) {
          var card = mycards[i];

          if (taken[card.idx]) {
            continue;
          }

          taken[card.idx] = true;
          break;
        }
      }

      console.log(sum);
    };

    for (var _iterator = X[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
      _loop();
    }
  } catch (err) {
    _didIteratorError = true;
    _iteratorError = err;
  } finally {
    try {
      if (!_iteratorNormalCompletion && _iterator.return != null) {
        _iterator.return();
      }
    } finally {
      if (_didIteratorError) {
        throw _iteratorError;
      }
    }
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  var arr = Array.isArray(line) ? line : line.split(/\s+/);
  return arr.map(function (n) {
    return parseInt(n);
  });
}
