#include <bits/stdc++.h>
const long long MAXN = 2e5 + 5;
long long t[MAXN], h[MAXN], n;
long long in[MAXN], out[MAXN];
struct Edge {
  long long to, nxt;
} e[MAXN << 1];
long long head[MAXN], cnt;
inline void add(long long u, long long v) {
  e[++cnt] = (Edge){v, head[u]};
  head[u] = cnt;
  e[++cnt] = (Edge){u, head[v]};
  head[v] = cnt;
}
long long f[MAXN], g[MAXN];
bool vis[MAXN];
long long sm[MAXN];
inline void dfs(long long v, long long fa = 0) {
  long long sz = 0;
  long long smg = 0;
  vis[v] = 1;
  for (long long i = head[v]; i; i = e[i].nxt) {
    if (e[i].to == fa) continue;
    dfs(e[i].to, v);
  }
  for (long long i = head[v]; i; i = e[i].nxt) {
    if (e[i].to == fa) continue;
    sm[++sz] = f[e[i].to] - g[e[i].to];
    smg += g[e[i].to];
  }
  std::sort(sm + 1, sm + sz + 1);
  std::reverse(sm + 1, sm + sz + 1);
  for (long long i = 1; i <= sz; ++i) sm[i] += sm[i - 1];
  out[v] += (bool)(fa);
  for (long long i = 0; i <= sz; ++i) {
    f[v] = std::max(f[v],
                    smg + sm[i] + std::min(in[v] + i, out[v] + sz - i) * t[v]);
  }
  out[v] -= (bool)(fa);
  in[v] += (bool)(fa);
  for (long long i = 0; i <= sz; ++i) {
    g[v] = std::max(g[v],
                    smg + sm[i] + std::min(in[v] + i, out[v] + sz - i) * t[v]);
  }
  in[v] -= (bool)(fa);
  for (long long i = 0; i <= sz; ++i) sm[i] = 0;
}
long long F[MAXN], G[MAXN], tot;
long long deg[MAXN];
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; ++i) scanf("%lld", t + i);
  for (long long i = 1; i <= n; ++i) scanf("%lld", h + i);
  for (long long i = 2; i <= n; ++i) {
    long long u, v;
    scanf("%lld%lld", &u, &v);
    deg[u]++;
    deg[v]++;
    if (h[u] > h[v]) std::swap(u, v);
    if (h[u] == h[v])
      add(u, v);
    else
      out[u]++, in[v]++;
  }
  for (long long i = 1; i <= n; ++i)
    if (!vis[i]) dfs(i), F[++tot] = f[i], G[tot] = g[i];
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) ans += deg[i] * t[i];
  for (long long i = 1; i <= tot; ++i) ans -= F[i];
  printf("%lld\n", ans);
  return 0;
}
