#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long mn = 6e5, inf = 1e18;
long long n, a[mn], p[mn], m, b[mn], dp[mn], second[mn], s1;
void add(long long i, long long x) {
  long long k = n - i + 1;
  while (k <= n) {
    second[k] += x;
    k += k & (-k);
  }
}
long long sum(long long i) {
  long long k = n - i + 1, cnt = 0;
  while (k > 0) {
    cnt += second[k];
    k -= k & (-k);
  }
  return cnt;
}
signed main() {
  iostream::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) cin >> p[i];
  cin >> m;
  for (long long j = 1; j <= m; j++) {
    cin >> b[j];
    dp[j] = inf;
  }
  b[m + 1] = b[m];
  for (long long i = 1; i <= n; i++) {
    long long l = 0, r = m + 1, j;
    while (l < r - 1) {
      long long mid = (l + r) / 2;
      if (b[mid] <= a[i])
        l = mid;
      else
        r = mid;
    }
    j = l;
    long long s_new = s1;
    if (p[i] < 0) s_new += p[i];
    if (b[j] == a[i] && j == 1 && dp[j - 1] != inf)
      dp[j] = min(dp[j], dp[j - 1] + sum(1) - (sum(b[j]) - sum(b[j] + 1)) -
                             sum(b[j] + 1) + s1 - s_new);
    else if (b[j] == a[i] && dp[j - 1] != inf)
      dp[j] = min(dp[j],
                  dp[j - 1] + sum(b[j - 1] + 1) - sum(b[j] + 1) + s1 - s_new);
    s1 = s_new;
    if (p[i] > 0) add(a[i], p[i]);
  }
  if (dp[m] == inf) {
    cout << "NO";
    exit(0);
  }
  dp[m] += sum(b[m] + 1) + s1;
  cout << "YES\n" << dp[m];
  return 0;
}
