#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct segTree {
 private:
  int n;
  vector<T> mx, mn, lazySet, sum, lazyAdd;
  void update(int i) {
    mx[i] = max(mx[2 * i], mx[2 * i + 1]);
    mn[i] = min(mn[2 * i], mn[2 * i + 1]);
    sum[i] = sum[2 * i] + sum[2 * i + 1];
  }
  void init(int l, int r, int i, vector<T> &vals) {
    if (l == r) {
      mn[i] = mx[i] = sum[i] = vals[l];
      return;
    }
    int m = (l + r) / 2;
    init(l, m, 2 * i, vals);
    init(m + 1, r, 2 * i + 1, vals);
    update(i);
  }
  void prop(int i, int l, int m, int r) {
    if (lazySet[i] != numeric_limits<T>::max()) {
      mx[2 * i] = mx[2 * i + 1] = mn[2 * i] = mn[2 * i + 1] = lazySet[2 * i] =
          lazySet[2 * i + 1] = lazySet[i];
      sum[2 * i] = (long long)(m - l + 1) * lazySet[i];
      sum[2 * i + 1] = (long long)(r - m) * lazySet[i];
      lazyAdd[2 * i] = 0;
      lazyAdd[2 * i + 1] = 0;
      lazySet[i] = numeric_limits<T>::max();
    }
    if (lazyAdd[i]) {
      mx[2 * i] += lazyAdd[i];
      mx[2 * i + 1] += lazyAdd[i];
      mn[2 * i] += lazyAdd[i];
      mn[2 * i + 1] += lazyAdd[i];
      sum[2 * i] += (long long)(m - l + 1) * lazyAdd[i];
      sum[2 * i + 1] += (long long)(r - m) * lazyAdd[i];
      lazyAdd[2 * i] += lazyAdd[i];
      lazyAdd[2 * i + 1] += lazyAdd[i];
      lazyAdd[i] = 0;
    }
  }
  void setSingle(int pos, T x, int l, int r, int i) {
    if (l == r) {
      mx[i] = x;
      mn[i] = x;
      sum[i] = x;
      return;
    }
    int m = (l + r) / 2;
    prop(i, l, m, r);
    if (pos <= m)
      setSingle(pos, x, l, m, 2 * i);
    else
      setSingle(pos, x, m + 1, r, 2 * i + 1);
    update(i);
  }
  void addSingle(int pos, T x, int l, int r, int i) {
    if (l == r) {
      mx[i] += x;
      mn[i] += x;
      sum[i] += x;
      return;
    }
    int m = (l + r) / 2;
    prop(i, l, m, r);
    if (pos <= m)
      addSingle(pos, x, l, m, 2 * i);
    else
      addSingle(pos, x, m + 1, r, 2 * i + 1);
    update(i);
  }
  void setRange(int qs, int qe, T x, int l, int r, int i) {
    if (qs > r || qe < l) return;
    if (qs <= l && qe >= r) {
      lazyAdd[i] = 0;
      mx[i] = mn[i] = lazySet[i] = x;
      sum[i] = (long long)(r - l + 1) * x;
      return;
    }
    int m = (l + r) / 2;
    prop(i, l, m, r);
    setRange(qs, qe, x, l, m, 2 * i);
    setRange(qs, qe, x, m + 1, r, 2 * i + 1);
    update(i);
  }
  void addRange(int qs, int qe, T x, int l, int r, int i) {
    if (qs > r || qe < l) return;
    if (qs <= l && qe >= r) {
      lazyAdd[i] += x;
      mx[i] += x;
      mn[i] += x;
      sum[i] += (long long)(r - l + 1) * x;
      return;
    }
    int m = (l + r) / 2;
    prop(i, l, m, r);
    addRange(qs, qe, x, l, m, 2 * i);
    addRange(qs, qe, x, m + 1, r, 2 * i + 1);
    update(i);
  }
  int getMx(int qs, int qe, int l, int r, int i) {
    if (qs > r || qe < l) return numeric_limits<T>::min();
    if (qs <= l && qe >= r) return mx[i];
    int m = (l + r) / 2;
    prop(i, l, m, r);
    return max(getMx(qs, qe, l, m, 2 * i), getMx(qs, qe, m + 1, r, 2 * i + 1));
  }
  int getMn(int qs, int qe, int l, int r, int i) {
    if (qs > r || qe < l) return numeric_limits<T>::max();
    if (qs <= l && qe >= r) return mn[i];
    int m = (l + r) / 2;
    prop(i, l, m, r);
    return min(getMn(qs, qe, l, m, 2 * i), getMn(qs, qe, m + 1, r, 2 * i + 1));
  }
  long long getSum(int qs, int qe, int l, int r, int i) {
    if (qs > r || qe < l) return 0;
    if (qs <= l && qe >= r) return sum[i];
    int m = (l + r) / 2;
    prop(i, l, m, r);
    return getSum(qs, qe, l, m, 2 * i) + getSum(qs, qe, m + 1, r, 2 * i + 1);
  }

 public:
  void init(int N) {
    n = N;
    int pwr = 1;
    while (pwr < 2 * n) pwr *= 2;
    mx.resize(pwr);
    mn.resize(pwr);
    sum.resize(pwr);
    lazyAdd.resize(pwr);
    lazySet.resize(pwr);
    for (int i = 0; i < pwr; i++)
      mx[i] = mn[i] = sum[i] = lazyAdd[i] = 0,
      lazySet[i] = numeric_limits<T>::max();
  }
  void init(vector<T> &vals) {
    init(vals.size());
    init(0, n - 1, 1, vals);
  }
  void singleSet(int pos, T x) { setSingle(pos, x, 0, n - 1, 1); }
  void singleAdd(int pos, T x) { addSingle(pos, x, 0, n - 1, 1); }
  void rangeSet(int qs, int qe, T x) { setRange(qs, qe, x, 0, n - 1, 1); }
  void rangeAdd(int qs, int qe, T x) { addRange(qs, qe, x, 0, n - 1, 1); }
  int getMax(int qs, int qe) { return getMx(qs, qe, 0, n - 1, 1); }
  int getMin(int qs, int qe) { return getMn(qs, qe, 0, n - 1, 1); }
  long long getSum(int qs, int qe) { return getSum(qs, qe, 0, n - 1, 1); }
};
segTree<long long> svi, neg;
const long long oo = LLONG_MAX / 2;
int main() {
  int n;
  scanf("%i", &n);
  vector<int> a(n + 2), pr(n + 2), b;
  for (int i = 1; i <= n; i++) scanf("%i", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%i", &pr[i]);
  int m;
  scanf("%i", &m);
  b.resize(m + 1);
  vector<int> pos(n + 1, -1);
  for (int i = 1; i <= m; i++) scanf("%i", &b[i]), pos[b[i]] = i;
  a[n + 1] = b[m];
  vector<int> last(n + 1, -1);
  last[0] = 0;
  vector<long long> dp(n + 2), veci(n + 2), manji(n + 2);
  svi.init(n + 1);
  neg.init(n + 1);
  for (int i = 1; i <= n + 1; i++) {
    dp[i] = oo;
    if (pos[a[i]] == -1) {
      svi.singleAdd(a[i], pr[i]);
      if (pr[i] < 0) neg.singleAdd(a[i], pr[i]);
      continue;
    }
    veci[i] = svi.getSum(a[i] + 1, n);
    manji[i] = neg.getSum(1, a[i] - 1);
    int p = pos[a[i]];
    if (last[b[p]] != -1) {
      int g = last[b[p]];
      long long tada = dp[g] + veci[i] - veci[g] + manji[i] - manji[g];
      if (pr[i] < 0) tada += pr[i];
      dp[i] = min(dp[i], tada);
    }
    if (i != n + 1 && last[b[p - 1]] != -1) {
      int g = last[b[p - 1]];
      int koji = b[p - 1];
      long long tada = dp[g] + svi.getSum(koji + 1, n) - veci[g] +
                       neg.getSum(1, koji - 1) - manji[g];
      dp[i] = min(dp[i], tada);
    }
    svi.singleAdd(a[i], pr[i]);
    if (pr[i] < 0) neg.singleAdd(a[i], pr[i]);
    last[a[i]] = i;
  }
  if (dp[n + 1] >= oo / 2)
    printf("NO\n");
  else
    printf("YES\n%lld\n", dp[n + 1]);
  return 0;
}
