#include <bits/stdc++.h>
using namespace std;
vector<long long> t, h;
vector<long long> in, out;
vector<int> gr[200002];
vector<int> used;
long long ans, v[200002], u[200002];
void solve(int ver, int p) {
  long long ss = 0;
  used[ver] = 1;
  vector<long long> pref;
  for (auto& x : gr[ver]) {
    if (x == p) continue;
    solve(x, ver);
    pref.push_back(v[x] - u[x]);
    ss += u[x];
  }
  sort(pref.begin(), pref.end());
  if (p == -1) {
    long long ret =
        max(in[ver], (long long)pref.size() + out[ver]) * t[ver] + ss;
    for (int i = 0; i < pref.size(); ++i) {
      ss += pref[i];
      ret = min(
          ret, max(i + 1 + in[ver], (long long)pref.size() - i - 1 + out[ver]) *
                       t[ver] +
                   ss);
    }
    ans += ret;
    return;
  }
  long long vs = ss;
  v[ver] = max(in[ver], (long long)pref.size() + out[ver] + 1) * t[ver] + ss;
  for (int i = 0; i < pref.size(); ++i) {
    ss += pref[i];
    v[ver] = min(v[ver], max(i + 1 + in[ver],
                             (long long)pref.size() - i - 1 + out[ver] + 1) *
                                 t[ver] +
                             ss);
  }
  ss = vs;
  u[ver] = max(in[ver] + 1, (long long)pref.size() + out[ver]) * t[ver] + ss;
  for (int i = 0; i < pref.size(); ++i) {
    ss += pref[i];
    u[ver] = min(u[ver], max(i + 1 + in[ver] + 1,
                             (long long)pref.size() - i - 1 + out[ver]) *
                                 t[ver] +
                             ss);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  t.resize(n);
  h.resize(n);
  in.resize(n);
  out.resize(n);
  used.resize(n);
  for (auto& x : t) {
    cin >> x;
  }
  for (auto& x : h) {
    cin >> x;
  }
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (h[a] > h[b]) {
      out[b]++;
      in[a]++;
    } else if (h[a] < h[b]) {
      out[a]++;
      in[b]++;
    } else {
      gr[a].push_back(b);
      gr[b].push_back(a);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (!used[i]) solve(i, -1);
  }
  cout << ans;
}
