#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
long long n, m, a[N], b[N], p[N];
long long cost[N], dp[N], Minus;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], dp[i] = 1e18;
  for (int i = 1; i <= n; i++) cin >> p[i];
  cin >> m;
  for (int i = 1; i <= m; i++) cin >> b[i];
  b[m + 1] = 1e18;
  for (int i = 1; i <= n; i++) {
    int j = lower_bound(b + 1, b + m + 2, a[i]) - b;
    if (j == m + 1)
      cost[j] += p[i];
    else if (p[i] < 0)
      cost[j] += p[i];
  }
  for (int i = 1; i <= n; i++) {
    int j = lower_bound(b + 1, b + m + 2, a[i]) - b;
    if (j == m + 1) continue;
    if (b[j] == a[i] && dp[j - 1] != 1e18)
      dp[j] = min(dp[j], dp[j - 1] + cost[j] - (p[i] < 0 ? p[i] : 0));
    if (p[i] > 0) cost[j] += p[i];
  }
  if (dp[m] == 1e18) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
    cout << dp[m] + cost[m + 1] << "\n";
  }
  return 0;
}
