#include <bits/stdc++.h>
using namespace std;
template <class T>
struct Fenwick {
  vector<T> bit;
  int N;
  Fenwick(int n) : N(n) { bit.assign(n + 1, 0); }
  void add(int a, T w) {
    for (int x = ++a; x <= N; x += x & -x) bit[x] += w;
  }
  T sum(int a) {
    T ret = 0;
    for (int x = a; x > 0; x -= x & -x) ret += bit[x];
    return ret;
  }
  T sum(int a, int b) { return sum(b) - sum(a); }
};
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<long long> c(n);
  for (auto &x : a) cin >> x;
  for (auto &x : c) cin >> x;
  int m;
  cin >> m;
  vector<int> b(m);
  for (auto &x : b) cin >> x;
  Fenwick<long long> f(m + 2);
  vector<long long> dp(m + 1, 1e18);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    int j = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
    int k = upper_bound(b.begin(), b.end(), a[i]) - b.begin();
    long long e = min(0LL, c[i]);
    long long y = 1e18;
    if (j != m && b[j] == a[i]) y = dp[j] + f.sum(j + 1);
    f.add(0, c[i]);
    f.add(j + 1, e - c[i]);
    if (j != m && b[j] == a[i]) {
      dp[j + 1] = min(dp[j + 1], y - f.sum(j + 2));
    }
  }
  if (dp[m] >= 1e16) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  cout << f.sum(m + 1) + dp[m] << "\n";
  return 0;
}
