#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const long long INF = (1ll << 60);
int n;
int hgt[N], val[N];
long long f[N][2], tmp[N], ans;
struct GRAPH {
  int head[N], to[N << 1], nxt[N << 1], ncnt;
  void AddEdge(const int& u, const int& v) {
    int p = ++ncnt, q = ++ncnt;
    to[p] = v, nxt[p] = head[u], head[u] = p;
    to[q] = u, nxt[q] = head[v], head[v] = q;
  }
  inline int operator[](const int& u) { return head[u]; }
} Gr;
inline int Read() {
  register int r = 0, c = getchar();
  while (c < '0' || '9' < c) c = getchar();
  while ('0' <= c && c <= '9')
    r = (r << 1) + (r << 3) + (c ^ '0'), c = getchar();
  return r;
}
void DP(const int& u, const int& fa) {
  long long sum = 0;
  f[u][0] = f[u][1] = INF;
  int in = 0, out = 0;
  for (int it = Gr[u]; it; it = Gr.nxt[it]) {
    int v = Gr.to[it];
    if (v == fa) continue;
    DP(v, u);
    if (hgt[v] < hgt[u]) sum += f[v][0], in++;
    if (hgt[v] > hgt[u]) sum += f[v][1], out++;
  }
  int ntmp = 0;
  for (int it = Gr[u]; it; it = Gr.nxt[it]) {
    int v = Gr.to[it];
    if (v == fa || hgt[v] != hgt[u]) continue;
    sum += f[v][1];
    tmp[++ntmp] = f[v][0] - f[v][1];
    out++;
  }
  sort(tmp + 1, tmp + 1 + ntmp);
  for (int i = 0; i <= ntmp; i++, in++, out--, sum += tmp[i]) {
    if (u == 1)
      ans = min(ans, sum + 1ll * max(in, out) * val[u]);
    else {
      f[u][0] = min(f[u][0], sum + 1ll * max(in, out + 1) * val[u]);
      f[u][1] = min(f[u][1], sum + 1ll * max(in + 1, out) * val[u]);
    }
  }
}
int main() {
  n = Read();
  for (int i = 1; i <= n; i++) val[i] = Read();
  for (int i = 1; i <= n; i++) hgt[i] = Read();
  for (int i = 1; i < n; i++) Gr.AddEdge(Read(), Read());
  ans = INF;
  DP(1, 0);
  printf("%lld\n", ans);
  return 0;
}
