#include <bits/stdc++.h>
using namespace std;
const int N = 100005, inf = 0x3f3f3f3f;
int read() {
  int f = 1, g = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) g = g * 10 + ch - '0';
  return f * g;
}
int n, m, L, a[N], b[N], h[N], fr[N], f[N], g[N], pre[N];
void trans() {
  int i = 0, j = m;
  for (i = L; i >= 0; i--) {
    while ((j) && (b[j - 1] > f[i])) j--;
    if ((b[j] > f[i]) && (b[j] <= f[i + 1])) {
      f[i + 1] = b[j];
      pre[i + 1] = pre[i];
      if (i == L) L++;
    }
  }
}
int getlis() {
  memset(f, 0x3f, sizeof(f));
  L = 0;
  f[0] = 0;
  for (int i = 1; i <= n; i++) {
    int pos = lower_bound(f + 1, f + L + 1, a[i]) - f;
    if (pos > L) L++;
    f[pos] = a[i];
  }
  return L;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  m = read();
  for (int i = 1; i <= m; i++) b[i] = read();
  sort(b + 1, b + m + 1);
  memset(f, 0x3f, sizeof(f));
  L = 0;
  f[0] = 0;
  a[n + 1] = 1000000001;
  for (int i = 1; i <= n + 1; i++)
    if (a[i] > 0) {
      int pos = lower_bound(f + 1, f + L + 1, a[i]) - f;
      if (pos > L) L++;
      f[pos] = a[i];
      pre[pos] = i;
      fr[i] = pre[pos - 1];
      g[i] = pos;
    } else
      trans();
  int j = m;
  for (int i = n + 1; i; i = fr[i]) {
    int l = a[fr[i]], r = a[i];
    for (int x = i - 1; x > fr[i]; x--)
      if (a[x] < 0) {
        while (j && (b[j] >= r)) j--;
        if (j && (b[j] > l)) {
          a[x] = r = b[j];
          h[j] = 1;
        }
      }
  }
  j = 1;
  for (int i = 1; i <= n; i++)
    if (a[i] < 0) {
      while (h[j]) j++;
      h[j] = 1;
      a[i] = b[j];
    }
  for (int i = 1; i <= n; i++) printf("%d ", a[i]);
  printf("\n");
  return 0;
}
