#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
const long long MOD = 1000000007;
int n, m, v[MAXN], a[MAXN], b[MAXN];
long long dp[MAXN];
struct BIT {
  bool rev;
  long long bit[MAXN];
  BIT(bool _rev) {
    rev = _rev;
    memset(bit, 0, sizeof(bit));
  }
  void add(int x, int val) {
    x++;
    if (rev) {
      x = n - x + 2;
    }
    for (; x < MAXN; x += -x & x) {
      bit[x] += val;
    }
  }
  long long qry(int x) {
    long long res = 0;
    x++;
    if (rev) {
      x = n - x + 2;
    }
    for (; x > 0; x -= -x & x) {
      res += bit[x];
    }
    return res;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a[n] = n + 1;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
  }
  b[m + 1] = n + 1;
  memset(dp, 0x3f, sizeof(dp));
  dp[0] = 0;
  BIT pre(0);
  BIT suf(1);
  for (int i = 0; i <= n; i++) {
    int c = lower_bound(b, b + m + 2, a[i]) - b;
    long long gtp = suf.qry(b[c - 1] + 1);
    long long lep = pre.qry(b[c - 1]);
    long long cdp = dp[c - 1] + gtp + lep;
    ;
    if (i < n) {
      suf.add(a[i], v[i]);
      pre.add(a[i], min(0, v[i]));
      gtp = suf.qry(b[c] + 1);
      lep = pre.qry(b[c]);
      ;
      cdp = cdp - gtp - lep;
    }
    if (b[c] == a[i]) {
      dp[c] = min(dp[c], cdp);
      ;
    }
  }
  if (dp[m + 1] > 1e15) {
    cout << "NO" << '\n';
  } else {
    cout << "YES" << '\n';
    cout << dp[m + 1] << '\n';
  }
}
