#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void chkmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void chkmin(T &a, T b) {
  if (a > b) a = b;
}
inline int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') ch = getchar(), f = -1;
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return ~f ? s : -s;
}
const int maxn = 2e5 + 20;
const long long inf = 1ll << 40;
int n, t[maxn], h[maxn];
vector<int> ed[maxn];
inline void init() {
  n = read();
  for (int i = (1), _end_ = (n); i <= _end_; i++) t[i] = read();
  for (int i = (1), _end_ = (n); i <= _end_; i++) h[i] = read();
  for (int i = (1), _end_ = (n - 1); i <= _end_; i++) {
    int u = read(), v = read();
    ed[u].push_back(v);
    ed[v].push_back(u);
  }
}
long long dp[maxn][2];
void dfs(int u, int fa) {
  for (int v : ed[u]) {
    if (v == fa) continue;
    dfs(v, u);
  }
  static long long f[2];
  f[0] = f[1] = -inf;
  for (int op = (0), _end_ = (1); op <= _end_; op++) {
    if (op == 0) {
      if ((h[u] <= h[fa]))
        ;
      else
        continue;
    }
    if (op == 1) {
      if ((h[u] >= h[fa]))
        ;
      else
        continue;
    }
    dp[fa][op] = -inf;
    dp[fa][op ^ 1] = 0;
    long long res = 0;
    for (int p = (0), _end_ = (1); p <= _end_; p++) {
      long long ans = 0;
      static long long st[maxn];
      int top = 0;
      for (int v : ed[u]) {
        long long a = dp[v][0] + (p == 0) * t[u],
                  b = dp[v][1] + (p == 1) * t[u];
        ans += p == 0 ? b : a;
        st[++top] = p == 0 ? a - b : b - a;
      }
      sort(st + 1, st + top + 1,
           [](long long a, long long b) { return a > b; });
      for (int i = (1), _end_ = (top >> 1); i <= _end_; i++)
        ans += max(st[i], 0ll);
      chkmax(res, ans);
    }
    chkmax(res, -inf);
    f[op] = res;
  }
  dp[u][0] = f[0];
  dp[u][1] = f[1];
}
inline void doing() {
  dfs(1, 0);
  long long num = 0;
  for (int i = (1), _end_ = (n); i <= _end_; i++)
    num += (long long)t[i] * ((int)ed[i].size());
  printf("%lld\n", num - max(dp[1][0], dp[1][1]));
}
int main() {
  init();
  doing();
  return 0;
}
