#include <bits/stdc++.h>
using namespace std;
char buf[1 << 21], *p1 = buf, *p2 = buf, obuf[1 << 23], *O = obuf;
inline int read() {
  int x = 0, sign = 0;
  char s = getchar();
  while (!isdigit(s)) sign |= s == '-', s = getchar();
  while (isdigit(s)) x = (x << 1) + (x << 3) + (s - '0'), s = getchar();
  return sign ? -x : x;
}
void print(int x) {
  if (x > 9) print(x / 10);
  (*O++ = x % 10 + '0');
}
const int N = 5e5 + 5;
vector<int> buc[N];
long long n, m, a[N], b[N], p[N], f[N], c[N];
void modify(int x, int v) {
  while (x <= n) c[x] += v, x += x & -x;
}
long long query(int x) {
  long long ans = 0;
  while (x) ans += c[x], x -= x & -x;
  return ans;
}
long long cal(int l, int r) { return (query(r) - query(l - 1)); }
int main() {
  n = read(), memset(f, 0x3f, sizeof(f));
  for (int i = 1; i <= n; i++) a[i] = read(), buc[a[i]].push_back(i);
  for (int i = 1; i <= n; i++) p[i] = read(), modify(i, p[i]);
  m = read();
  for (int i = 1; i <= m; i++) b[i] = read();
  int pos = 0;
  for (int i = 1; i <= m; i++) {
    int pp = lower_bound(buc[b[i]].begin(), buc[b[i]].end(), pos) -
             buc[b[i]].begin();
    if (pp == buc[b[i]].size()) puts("NO"), exit(0);
    pos = buc[b[i]][pp];
  }
  puts("YES");
  b[0] = f[0] = 0, b[++m] = n + 1, buc[0].push_back(0),
  buc[n + 1].push_back(n + 1);
  for (int i = 1; i <= m; i++) {
    if (i > 1)
      for (int j = b[i - 2] + 1; j <= b[i - 1]; j++)
        for (int k : buc[j])
          if (p[k] > 0) modify(k, -p[k]);
    int pos = -1, sz = buc[b[i - 1]].size() - 1;
    for (int j = 0; j < buc[b[i]].size(); j++) {
      int k = buc[b[i]][j];
      if (j) f[k] = f[buc[b[i]][j - 1]] + cal(buc[b[i]][j - 1], k - 1);
      while (pos < sz && buc[b[i - 1]][pos + 1] < k) {
        int l = buc[b[i - 1]][++pos];
        f[k] = min(f[k], f[l] + cal(l + 1, k - 1));
      }
    }
  }
  cout << f[n + 1] << endl;
  return 0;
}
