#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct outputer;
struct outputable {};
template <typename T>
inline auto sqr(T x) -> decltype(x * x) {
  return x * x;
}
template <typename T1, typename T2>
inline bool umx(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool umn(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 200000;
const int64_t X = 1000000;
struct Input {
  int n;
  int64_t t[N];
  int h[N];
  vector<int> e[N];
  bool read() {
    if (!(cin >> n)) {
      return 0;
    }
    for (int i = int(0); i < int(n); ++i) {
      scanf("%" SCNd64, &t[i]);
    }
    for (int i = int(0); i < int(n); ++i) {
      scanf("%d", &h[i]);
    }
    for (int i = int(0); i < int(n - 1); ++i) {
      int x, y;
      scanf("%d%d", &x, &y);
      --x;
      --y;
      e[x].emplace_back(y);
      e[y].emplace_back(x);
    }
    return 1;
  }
  void init(const Input& input) { *this = input; }
};
struct Data : Input {
  int64_t ans;
  void write() { cout << ans << endl; }
};
namespace Main {
int64_t inf = 2 * N * X;
struct Solution : Data {
  tuple<int64_t, int64_t, int64_t> rec(int v, int pr) {
    ;
    int64_t res_no = inf, res_l = inf, res_g = inf;
    int64_t tot = 0;
    vector<int64_t> diffs;
    for (int to : e[v]) {
      if (to == pr) {
        continue;
      }
      auto cur = rec(to, v);
      tot += get<1>(cur);
      diffs.emplace_back(get<2>(cur) - get<1>(cur));
    }
    sort((diffs).begin(), (diffs).end());
    for (int i = int(0); i < int(((int)(diffs).size()) + 1); ++i) {
      umn(res_no, tot + max(i, ((int)(diffs).size()) - i) * t[v]);
      umn(res_l, tot + max(i + 1, ((int)(diffs).size()) - i) * t[v]);
      umn(res_g, tot + max(i, ((int)(diffs).size()) - i + 1) * t[v]);
      if (i < ((int)(diffs).size())) {
        tot += diffs[i];
      }
    }
    if (pr != -1 && h[pr] > h[v]) {
      res_g = inf;
    }
    if (pr != -1 && h[pr] < h[v]) {
      res_l = inf;
    }
    return make_tuple(res_no, res_l, res_g);
  }
  void solve() { ans = get<0>(rec(0, -1)); }
  void clear() { *this = Solution(); }
};
}  // namespace Main
Main::Solution sol;
int main() {
  cout.setf(ios::showpoint | ios::fixed);
  cout.precision(20);
  sol.read();
  sol.solve();
  sol.write();
  return 0;
}
