Problem: Let's denote the following function f. This function takes an array a of length n and returns an array. Initially the result is an empty array. For each integer i from 1 to n we add element a_i to the end of the resulting array if it is greater than all previous elements (more formally, if a_i > max_{1 ≤ j < i}a_j). Some examples of the function f:

  1. if a = [3, 1, 2, 7, 7, 3, 6, 7, 8] then f(a) = [3, 7, 8]; 
  2. if a = [1] then f(a) = [1]; 
  3. if a = [4, 1, 1, 2, 3] then f(a) = [4]; 
  4. if a = [1, 3, 1, 2, 6, 8, 7, 7, 4, 11, 10] then f(a) = [1, 3, 6, 8, 11]. 



You are given two arrays: array a_1, a_2, ... , a_n and array b_1, b_2, ... , b_m. You can delete some elements of array a (possibly zero). To delete the element a_i, you have to pay p_i coins (the value of p_i can be negative, then you get |p_i| coins, if you delete this element). Calculate the minimum number of coins (possibly negative) you have to spend for fulfilling equality f(a) = b.

Input

The first line contains one integer n (1 ≤ n ≤ 5 ⋅ 10^5) — the length of array a.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n) — the array a.

The third line contains n integers p_1, p_2, ..., p_n (|p_i| ≤ 10^9) — the array p.

The fourth line contains one integer m (1 ≤ m ≤ n) — the length of array b.

The fifth line contains m integers b_1, b_2, ..., b_m (1 ≤ b_i ≤ n, b_{i-1} < b_i) — the array b.

Output

If the answer exists, in the first line print YES. In the second line, print the minimum number of coins you have to spend for fulfilling equality f(a) = b.

Otherwise in only line print NO.

Examples

Input


11
4 1 3 3 7 8 7 9 10 7 11
3 5 0 -2 5 3 6 7 8 2 4
3
3 7 10


Output


YES
20


Input


6
2 1 5 3 6 5
3 -9 0 16 22 -14
4
2 3 5 6


Output


NO

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using std::to_string;
std::string to_string(const std::string &s) { return '"' + s + '"'; }
std::string to_string(const char *s) { return to_string((std::string)s); }
std::string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
std::string to_string(const std::pair<A, B> &p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <size_t N>
std::string to_string(const std::bitset<N> &bs) {
  return bs.to_string();
}
template <typename A>
std::string to_string(const A &v) {
  bool first = true;
  std::string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_out(const Head &H, const Tail &...T) {
  std::cerr << " " << to_string(H);
  debug_out(T...);
}
struct fast_ios {
  fast_ios() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
  };
} fast_ios_;
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &vec) {
  for (auto &x : vec) stream >> x;
  return stream;
}
template <typename T, typename U>
std::istream &operator>>(std::istream &in, std::pair<T, U> &p) {
  in >> p.first >> p.second;
  return in;
}
void scan() {}
template <class T, class... Args>
void scan(T &a, Args &...rest) {
  std::cin >> a;
  scan(rest...);
}
template <typename T>
std::ostream &operator<<(std::ostream &stream, const std::vector<T> &vec) {
  bool first = true;
  for (const T &t : vec) {
    if (first)
      first = false;
    else
      std::cout << ' ';
    std::cout << t;
  }
  return stream;
}
template <typename T, typename U>
std::ostream &operator<<(std::ostream &out, const std::pair<T, U> &p) {
  out << p.first << ' ' << p.second;
  return out;
}
template <typename T>
void print(const std::vector<std::vector<T>> &t) {
  for (const auto &row : t) {
    std::cout << row << '\n';
  }
}
template <typename T>
void print(const T &t) {
  std::cout << t << ' ';
}
template <typename T, typename... Args>
void print(const T &t, const Args &...rest) {
  print(t);
  print(rest...);
}
template <typename T>
void println(const T &t) {
  std::cout << t << '\n';
}
template <typename T, typename... Args>
void println(const T &t, const Args &...rest) {
  print(t);
  println(rest...);
}
template <typename A, typename B>
bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename A, typename B>
bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}
using ll = long long;
using ull = unsigned long long;
using vl = std::vector<ll>;
using vb = std::vector<bool>;
using vi = std::vector<int>;
using pii = std::pair<int, int>;
using pli = std::pair<ll, int>;
using pil = std::pair<int, ll>;
using pll = std::pair<ll, ll>;
using vpii = std::vector<pii>;
template <typename T>
using vv = std::vector<std::vector<T>>;
template <typename T, typename U = std::less<T>>
using pq = std::priority_queue<T, std::vector<T>, U>;
template <typename T, typename U>
T ceil(T x, U y) {
  assert(y > 0);
  if (x > 0) x += y - 1;
  return x / y;
}
template <typename T, typename U>
T floor(T x, U y) {
  assert(y > 0);
  if (x < 0) x -= y - 1;
  return x / y;
}
using namespace std;
template <typename T>
class BIT {
  using BinOp = function<T(T, T)>;
  BinOp bin_op;
  const T init;
  vector<T> a;

 public:
  explicit BIT(
      int n, BinOp op = [](T x, T y) { return x + y; }, T init = T{})
      : bin_op(std::move(op)), init(init), a(n, init) {}
  T prefix(int x) const {
    auto res = init;
    while (x >= 0) {
      res = bin_op(a[x], res);
      x = (x & (x + 1)) - 1;
    }
    return res;
  }
  void modify(int x, T v) {
    while (x < (int)(a).size()) {
      a[x] = bin_op(a[x], v);
      x |= (x + 1);
    }
  }
  void clear() { fill(a.begin(), a.end(), init); }
};
class FStrangeFunction {
 public:
  static void solve(int, int) {
    int n;
    scan(n);
    vv<int> pos(n + 1);
    for (std::common_type<decltype(0), decltype(n)>::type i = 0; i < n; ++i) {
      int x;
      scan(x);
      pos[x].push_back(i);
    }
    vi p(n);
    scan(p);
    int m;
    scan(m);
    vi b(m + 1);
    b[0] = 0;
    for (std::common_type<decltype(1), decltype(m)>::type i = 1; i <= m; ++i)
      scan(b[i]);
    BIT<ll> c(n);
    for (std::common_type<decltype(0), decltype(n)>::type i = 0; i < n; ++i)
      c.modify(i, p[i]);
    vector<pair<int, ll>> cand, cand2;
    cand.emplace_back(-1, 0);
    for (std::common_type<decltype(1), decltype(m)>::type i = 1; i <= m; ++i) {
      int j = 0;
      for (const auto &x : pos[b[i]]) {
        if (x < cand[j].first) continue;
        while (j + 1 < cand.size() && cand[j + 1].first < x) ++j;
        ll cost = cand[j].second + c.prefix(x - 1) - c.prefix(cand[j].first);
        cand2.emplace_back(x, cost);
      }
      if (cand2.empty()) {
        println("NO");
        return;
      }
      for (std::common_type<decltype(b[i - 1] + 1), decltype(b[i])>::type k =
               b[i - 1] + 1;
           k <= b[i]; ++k) {
        for (const auto &y : pos[k])
          if (p[y] > 0) c.modify(y, -p[y]);
      }
      cand.clear();
      cand.push_back(cand2[0]);
      for (std::common_type<decltype(1), decltype((int)(cand2).size())>::type
               k = 1;
           k < (int)(cand2).size(); ++k) {
        ll delta = c.prefix(cand2[k].first) - c.prefix(cand.back().first);
        if (cand2[k].second < cand.back().second + delta) {
          cand.push_back(cand2[k]);
        }
      }
      cand2.clear();
    }
    println("YES");
    println(cand.back().second + c.prefix(n - 1) - c.prefix(cand.back().first));
  }
};
int main() {
  FStrangeFunction solver;
  solver.solve(0, 0);
  return 0;
}