#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using db = long double;
using ii = pair<int, int>;
const int N = 1e5 + 5, LG = 17, MOD = 998244353;
const int SQ = 225;
const long double EPS = 1e-7;
int n, m, a[N], b[N];
set<int> pos[N];
bool vis[N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n + 1; i++) cin >> a[i];
  cin >> m;
  for (int i = 1; i < m + 1; i++) cin >> b[i];
  sort(b + 1, b + m + 1);
  vector<int> lis;
  for (int i = 1; i < n + 1; i++) {
    if (a[i] == -1) {
      int p = lower_bound(lis.begin(), lis.end(), b[m]) - lis.begin();
      if (p == lis.size()) lis.push_back(INT_MAX);
      for (int j = m; j; --j) {
        while (p > 0 && b[j] <= lis[p - 1]) --p;
        lis[p] = min(lis[p], b[j]);
      }
    } else {
      int p = lower_bound(lis.begin(), lis.end(), a[i]) - lis.begin();
      if (p == lis.size()) lis.push_back(0);
      lis[p] = a[i];
      pos[p].insert(i);
    }
  }
  int idx = n, prv = INT_MAX, ptr = m;
  for (int i = lis.size() - 1; i >= 0; --i) {
    auto it = pos[i].upper_bound(idx);
    if (it != pos[i].begin()) {
      --it;
      if (a[*it] < prv) {
        idx = *it;
        prv = a[idx];
        continue;
      }
    }
    while (~a[idx]) --idx;
    while (b[ptr] >= prv) --ptr;
    prv = a[idx] = b[ptr];
    vis[ptr] = true;
  }
  int tmp = 1;
  for (int i = 1; i < n + 1; i++) {
    while (tmp <= m && vis[tmp]) tmp++;
    if (a[i] == -1) a[i] = b[tmp++];
    cout << a[i] << " \n"[i == n];
  }
  return 0;
}
