#include <bits/stdc++.h>
using namespace std;
const long long det = 100000000000ll;
const long long inf = 10000000000000ll;
long long f[200009][2];
vector<long long> g;
int n, hd[200009], to[200009 << 1], nex[200009 << 1], ti[200009], hi[200009],
    edges;
void add(int u, int v) { nex[++edges] = hd[u], hd[u] = edges, to[edges] = v; }
void dfs(int u, int ff) {
  int son = 0;
  for (int i = hd[u]; i; i = nex[i]) {
    int v = to[i];
    if (v == ff) continue;
    dfs(v, u), ++son;
  }
  int u0 = 0, u1 = 0;
  long long sum = 0, tp = 0ll;
  g.clear(), g.push_back(-inf - inf);
  for (int i = hd[u]; i; i = nex[i]) {
    int v = to[i];
    if (v == ff) continue;
    sum += f[v][1];
    g.push_back(f[v][0] - f[v][1]);
  }
  sort(g.begin(), g.end()), g[0] = 0;
  for (int i = 0; i < g.size(); ++i) {
    tp += g[i];
    int pi = i + u0;
    f[u][0] =
        min(f[u][0], sum + tp + 1ll * max(pi, son - pi + (u != 1)) * ti[u]);
    f[u][1] =
        min(f[u][1], sum + tp + 1ll * max(pi + (u != 1), son - pi) * ti[u]);
  }
  if (u != 1) {
    if (hi[u] > hi[ff]) f[u][1] = inf;
    if (hi[u] < hi[ff]) f[u][0] = inf;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) f[i][0] = f[i][1] = inf;
  for (int i = 1; i <= n; ++i) scanf("%d", &ti[i]);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &hi[i]);
  }
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y), add(x, y), add(y, x);
  }
  dfs(1, 0), printf("%lld\n", min(f[1][0], f[1][1]));
  return 0;
}
