// UUID: dda06e14-2abe-4ed6-a9e8-450076f1f4ca
#include <iostream>
#include <vector>
#include <set> // Include the header for multiset
const int MAX_N = 1e5;
int a[MAX_N];
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int n, k;
std::cin >> n >> k;
for (int i = 0; i < n; ++i) {
std::cin >> a[i];
}
for (; k > 0; --k) {
int p;
std::cin >> p;
// Use std::multiset to correctly handle duplicate cards while keeping them sorted.
std::multiset<int> available_cards;
for (int i = 0; i < p; ++i) {
available_cards.insert(a[i]);
}
int pocket = 0;
long long score = 0;
int player = 1;
// This variable correctly mimics the stateful 'mx' from the original logic.
// It's the boundary used to decide where the opponent's next card goes.
int mx_boundary = n;
// --- Main game simulation loop 1 ---
for (int i = p; i < n; ++i, player *= -1) {
int card_to_play;
if (pocket) {
card_to_play = pocket;
score += (long long)card_to_play * player;
pocket = 0;
// Note: mx_boundary is NOT updated when playing from the pocket.
} else {
// Get the largest element from the hand.
auto it = prev(available_cards.end());
card_to_play = *it;
available_cards.erase(it);
score += (long long)card_to_play * player;
// CRUCIAL: Update the boundary ONLY when a card is played from the hand.
mx_boundary = card_to_play;
}
// The opponent draws card a[i]. The comparison uses the persistent boundary.
if (a[i] <= mx_boundary) {
available_cards.insert(a[i]);
} else {
pocket = a[i];
}
}
// --- Final turns simulation loop 2 ---
// This loop now correctly simulates the end-game using the remaining cards.
for (int i = 0; i < p; ++i, player *= -1) {
if (pocket) {
score += (long long)pocket * player;
pocket = 0;
} else {
if (!available_cards.empty()) {
auto it = prev(available_cards.end());
int mx = *it;
available_cards.erase(it);
score += (long long)mx * player;
}
}
}
std::cout << score << '\n';
}
return 0;
}