#include <iostream>

int fenwick[200010];

// Update operacija za fenwick tree
void update(int n, int index, int value)
{
	while (index <= n)
	{
		fenwick[index] += value;
		index += index & -index;
	}
}

// Sum operacija za fenwick tree
int sum(int fenwick[], int index)
{
	int sum = 0;
	while (index > 0)
	{
		sum += fenwick[index];
		index -= index & -index;
	}

	return sum;
}

int main() {
    int n, q, a[200010];
    bool taken[200010] = { 0 };
    std::cin >> n >> q;

    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }

    while (q--) {
        int p;
        std::cin >> p;

        int low = 1, high = n;

        // Binarna pretraga
        int ans = p;
        int ansIndex = p;
        while (low <= high) {
            int mid = low + (high - low) / 2;
            int posOfMid = (mid - sum(fenwick, mid - 1));

            if (posOfMid == p && !taken[mid]) {
                ans = a[mid - 1];
                ansIndex = mid;
                break;
            } else if (posOfMid <= p) {
                low = mid + 1;
            } else if (posOfMid > p) {
                high = mid - 1;
            }
        }

        std::cout << ans << " ";
        taken[ansIndex] = true;
        update(n, ansIndex, 1);
    }
}