#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
const long long inf = 1e17 + 10;
int n;
int a[maxn];
int p[maxn];
int m;
long long b[maxn];
long long dp[maxn];
long long cost[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  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] = inf;
  for (int i = 1; i <= n; i++) {
    int j = lower_bound(b + 1, b + m + 2, a[i]) - b;
    if (p[i] < 0 || j > m) cost[j] += p[i];
  }
  dp[0] = 0;
  for (int i = 1; i <= m; i++) dp[i] = inf;
  for (int i = 1; i <= n; i++) {
    int j = lower_bound(b + 1, b + m + 2, a[i]) - b;
    if (j <= m) {
      if (a[i] == b[j]) {
        if (p[i] < 0)
          dp[j] = min(dp[j], dp[j - 1] + cost[j] - p[i]);
        else
          dp[j] = min(dp[j], dp[j - 1] + cost[j]);
      }
      if (p[i] > 0) cost[j] += p[i];
    }
  }
  if (dp[m] > 1e14) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    cout << (dp[m] + cost[m + 1]) << endl;
  }
}
