#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> Tree;
void BuildTree(int tidx, int low, int high)
{
if (low == high)
{
Tree[tidx] = 1;
return;
}
int mid = (low + high) >> 1ll;
BuildTree(2 * tidx + 1, low, mid);
BuildTree(2 * tidx + 2, mid + 1, high);
Tree[tidx] = Tree[2 * tidx + 1] + Tree[2 * tidx + 2];
return;
}
ll UpdateTree(int tidx, int low, int high, int val)
{
if (low == high)
{
Tree[tidx] = 0;
return low;
}
int mid = (low + high) >> 1ll;
ll res;
if (Tree[2 * tidx + 1] >= val)
{
res = UpdateTree(2 * tidx + 1, low, mid, val);
}
else
res = UpdateTree(2 * tidx + 2, mid + 1, high, val - Tree[2 * tidx + 1]);
Tree[tidx] = Tree[2 * tidx + 1] + Tree[2 * tidx + 2];
return res;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
vector<ll> arr(n);
for (ll i = 0; i < n; i++)
{
cin >> arr[i];
}
Tree.resize(4ll * n);
BuildTree(0, 0, n - 1);
ll k = n;
while (k--)
{
ll x;
cin >> x;
cout << arr[UpdateTree(0, 0, n - 1, x)] << " ";
}
cout << '\n';
return 0;
}