#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void Read(T &x) {
  int f = 1;
  char t = getchar();
  while (t < '0' || t > '9') {
    if (t == '-') f = -1;
    t = getchar();
  }
  x = 0;
  while (t >= '0' && t <= '9') {
    x = x * 10 + t - '0';
    t = getchar();
  }
  x *= f;
}
template <class T>
inline void chkmin(T &x, T y) {
  if (x > y) x = y;
}
template <class T>
inline void chkmax(T &x, T y) {
  if (x < y) x = y;
}
const int inf = 0x3f3f3f3f;
const int maxn = 100005;
const int maxk = 1005;
int n;
int m;
int a[maxn];
int b[maxn];
int len;
bool used[maxn];
pair<int, int> bl[maxn];
int f[maxn];
int g[maxn];
int pre[maxn];
int last[maxn];
int gap[maxn];
int ans[maxn];
void input() {
  Read(n);
  for (int i = 1; i <= n; i++) Read(a[i]);
  Read(m);
  for (int i = 1; i <= m; i++) Read(b[i]);
}
int find(int x) {
  int l = 0;
  int r = n;
  int mid;
  int res;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (x > f[mid]) {
      res = mid + 1;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return res;
}
void prepare() {
  sort(b + 1, b + m + 1);
  for (int i = 1; i <= m; i++) bl[i].first = b[i];
  len = unique(bl + 1, bl + m + 1) - bl - 1;
  for (int i = 1, j = 1; i <= len; i++) {
    while (bl[i].first != b[j]) j++;
    bl[i].second = j;
  }
  for (int i = 1; i <= n + 1; i++) {
    if (a[i] == -1) gap[i] = 1;
    gap[i] += gap[i - 1];
  }
}
int countn(int l, int r) {
  r = upper_bound(bl + 1, bl + len + 1, make_pair(r, inf)) - bl - 1;
  l = lower_bound(bl + 1, bl + len + 1, make_pair(l, 0)) - bl;
  return r - l + 1;
}
void solve() {
  memset(f, inf, sizeof(f));
  f[0] = 0, a[n + 1] = inf;
  for (int i = 1; i <= n + 1; i++) {
    if (a[i] == -1) {
      for (int j = n, p = len; p >= 1; p--) {
        while (bl[p].first <= f[j]) j--;
        f[j + 1] = bl[p].first;
        last[j + 1] = -1;
      }
    } else {
      int res = find(a[i]);
      f[res] = a[i];
      last[res] = i;
      pre[i] = last[res - 1];
      g[i] = res;
    }
  }
  int cur = n + 1;
  while (cur > 0) {
    ans[cur] = a[cur];
    if (pre[cur] != -1) {
      cur = pre[cur];
    } else {
      int nex = -1;
      int en;
      for (int i = cur - 1; i >= 0; i--) {
        if (a[i] != -1 && a[cur] > a[i] && g[cur] > g[i]) {
          en = g[cur] - g[i] - 1;
          if (gap[cur] - gap[i] >= en && countn(a[i] + 1, a[cur] - 1) >= en) {
            nex = i;
            break;
          }
        }
      }
      int st = lower_bound(bl + 1, bl + len + 1, make_pair(a[nex] + 1, 0)) - bl;
      for (int i = nex + 1, j = 0; i <= cur && j < en; i++) {
        if (a[i] == -1) {
          ans[i] = bl[st].first;
          used[bl[st++].second] = true;
          j++;
        }
      }
      cur = nex;
    }
  }
  for (int i = 1, j = 1; i <= n; i++) {
    if (!ans[i]) {
      if (a[i] == -1) {
        while (used[j]) j++;
        ans[i] = b[j++];
      } else {
        ans[i] = a[i];
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  printf("\n");
}
int main() {
  input();
  prepare();
  solve();
  return 0;
}
