#include <bits/stdc++.h>
using namespace std;
template <class T = int>
T read() {
  T x = 0;
  char ch = 0;
  bool f = false;
  while (!isdigit(ch)) f |= (ch = getchar()) == '-';
  for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ '0');
  return f ? -x : x;
}
const int N = 200200;
int t[N], h[N];
long long dp[N][2];
vector<int> es[N];
const long long INF = 1e18;
void dfs(int x, int fa = -1) {
  for (int v : es[x])
    if (v != fa) {
      dfs(v, x);
    }
  int dg = es[x].size();
  for (int u = 0; u < (int)(2); u++) {
    int oc = 0, ic = 0;
    if (fa != -1) (u ? oc : ic)++;
    bool ok = fa == -1 ? u == 0 : u ? h[x] <= h[fa] : h[fa] <= h[x];
    long long &d = dp[x][u];
    d = INF;
    priority_queue<long long> pq;
    long long cc = 0;
    if (ok) {
      for (int v : es[x])
        if (v != fa) {
          long long v0 = dp[v][0];
          long long v1 = dp[v][1];
          if (v0 < INF && v1 < INF) {
            oc++;
            cc += v0;
            pq.push(v0 - v1);
          } else if (v0 < INF) {
            oc++;
            cc += v0;
          } else {
            ic++;
            cc += v1;
          }
        }
      d = (cc + (long long)t[x] * (dg - min(oc, ic)));
      while (!pq.empty()) {
        cc -= pq.top();
        ic++;
        oc--;
        pq.pop();
        d = min(d, (cc + (long long)t[x] * (dg - min(oc, ic))));
      }
    }
  }
}
int main() {
  int n = read();
  for (int i = (int)(1); i <= (int)(n); i++) t[i] = read();
  for (int i = (int)(1); i <= (int)(n); i++) h[i] = read();
  for (int _ = 0; _ < (int)(n - 1); _++) {
    int u = read(), v = read();
    es[u].push_back(v);
    es[v].push_back(u);
  }
  dfs(1);
  long long ans = dp[1][0];
  printf("%lld\n", ans);
  return 0;
}
