#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool d = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') d = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return d ? x : -x;
}
inline unsigned long long rnd() {
  return ((unsigned long long)rand() << 30 ^ rand()) << 4 | rand() % 4;
}
const int N = 2e5 + 5;
int n, m, k, a[N], b[N], d[N], pre[N], f[N];
pair<int, int> c[N], dp[N], g[N], h[N];
void add(int x, pair<int, int> y) {
  assert(x > 0);
  for (int i = x; i <= k + 1; i += (i & -i)) c[i] = max(c[i], y);
}
pair<int, int> find(int x) {
  pair<int, int> res = make_pair(0, 0);
  for (int i = x; i; i -= (i & -i)) res = max(res, c[i]);
  return res;
}
vector<long long> v, rv;
bool used[N], vis[N];
int main() {
  n = read();
  for (int i = (int)(1); i <= (int)(n); i++) a[i] = read();
  m = read();
  for (int i = (int)(1); i <= (int)(m); i++) b[i] = read();
  for (int i = (int)(1); i <= (int)(n); i++)
    if (a[i] != -1) d[++k] = a[i];
  for (int i = (int)(1); i <= (int)(m); i++) d[++k] = b[i];
  sort(d + 1, d + k + 1);
  k = unique(d + 1, d + k + 1) - d - 1;
  for (int i = (int)(1); i <= (int)(n); i++)
    if (a[i] != -1) a[i] = lower_bound(d + 1, d + k + 1, a[i]) - d;
  a[n + 1] = k + 1;
  sort(b + 1, b + m + 1);
  for (int i = (int)(1); i <= (int)(m); i++)
    b[i] = lower_bound(d + 1, d + k + 1, b[i]) - d;
  for (int i = (int)(1); i <= (int)(n); i++)
    if (a[i] != -1) v.push_back(a[i]);
  sort(v.begin(), v.end());
  for (int i = (int)(1); i <= (int)(n + 1); i++) {
    if (a[i] == -1) {
      int now = 0;
      pair<int, int> mx = make_pair(0, 0);
      for (int j = (int)(1); j <= (int)(m); j++) {
        while (now < v.size() && v[now] < b[j]) mx = max(mx, g[v[now++]]);
        h[j] = dp[j];
        if (j == 1 || b[j] != b[j - 1])
          dp[j] = max(h[j - 1], mx), dp[j].first++;
        else
          dp[j] = dp[j - 1];
        dp[j] = max(dp[j], dp[j - 1]);
      }
    } else {
      int ksg = lower_bound(b + 1, b + m + 1, a[i]) - b - 1;
      pair<int, int> ssw = max(dp[ksg], find(a[i] - 1));
      pre[i] = ssw.second;
      ssw.first++;
      ssw.second = i;
      f[i] = ssw.first;
      add(a[i], ssw);
      g[a[i]] = max(g[a[i]], make_pair(f[i], i));
    }
  }
  v.clear();
  for (int i = (int)(1); i <= (int)(n); i++)
    if (a[i] == -1) v.push_back(i);
  rv.push_back(b[1]);
  for (int i = (int)(2); i <= (int)(m); i++)
    if (b[i] != b[i - 1]) rv.push_back(b[i]);
  int pos = n + 1;
  while (pos) {
    int alb = pre[pos];
    while (v.size() && v[(int)v.size() - 1] > pos) v.pop_back();
    while (rv.size() && rv[(int)rv.size() - 1] >= a[pos]) rv.pop_back();
    int cnt = 0;
    while (v.size() && cnt < f[pos] - f[alb] - 1) {
      int ksg = v[(int)v.size() - 1];
      used[ksg] = vis[rv[(int)rv.size() - 1]] = 1;
      a[ksg] = rv[(int)rv.size() - 1];
      cnt++;
      v.pop_back();
      rv.pop_back();
    }
    pos = alb;
  }
  v.clear();
  for (int i = (int)(1); i <= (int)(m); i++) {
    if (i == 1 || b[i] != b[i - 1]) {
      if (!vis[b[i]]) v.push_back(b[i]);
    } else
      v.push_back(b[i]);
  }
  for (int i = (int)(1); i <= (int)(n); i++)
    if (a[i] == -1 && !used[i]) {
      a[i] = v[(int)v.size() - 1];
      v.pop_back();
    }
  for (int i = (int)(1); i <= (int)(n); i++) printf("%d ", d[a[i]]);
}
