#include <bits/stdc++.h>
#pragma GCC optimize(2)
inline int rint() {
  int x = 0, f = 1;
  char s = getchar();
  for (; s < '0' || '9' < s; s = getchar()) f = s == '-' ? -f : f;
  for (; '0' <= s && s <= '9'; s = getchar()) x = x * 10 + (s ^ '0');
  return x * f;
}
template <typename Tp>
inline void wint(Tp x) {
  if (x < 0) putchar('-'), x = ~x + 1;
  if (9 < x) wint(x / 10);
  putchar(x % 10 ^ '0');
}
inline long long max_(const long long a, const long long b) {
  return a < b ? b : a;
}
inline void chkmin(long long& a, const long long b) {
  if (b < a) a = b;
}
const int MAXN = 2e5;
const long long INF = 1e13;
int n, ecnt, height[MAXN + 5], cost[MAXN + 5], head[MAXN + 5];
long long f[MAXN + 5][2], ans;
std::vector<long long> delta;
struct Edge {
  int to, nxt;
} graph[MAXN * 2 + 5];
inline void link(const int s, const int t) {
  graph[++ecnt] = {t, head[s]};
  head[s] = ecnt;
}
inline void solve(const int u, const int fa) {
  long long sum = 0, in = 0, out = 0;
  for (int i = head[u], v; i; i = graph[i].nxt) {
    if ((v = graph[i].to) ^ fa) {
      solve(v, u);
    }
  }
  for (int i = head[u], v; i; i = graph[i].nxt) {
    if ((v = graph[i].to) ^ fa) {
      if (height[u] < height[v]) {
        sum += f[v][0], ++out;
      } else if (height[u] > height[v]) {
        sum += f[v][1], ++in;
      } else {
        delta.push_back(f[v][0] - f[v][1]);
        sum += f[v][1], ++in;
      }
    }
  }
  f[u][0] = sum + max_(in + !!fa, out) * cost[u];
  f[u][1] = sum + max_(in, out + !!fa) * cost[u];
  std::sort(delta.begin(), delta.end());
  for (long long d : delta) {
    --in, ++out, sum += d;
    chkmin(f[u][0], sum + max_(in + !!fa, out) * cost[u]);
    chkmin(f[u][1], sum + max_(in, out + !!fa) * cost[u]);
  }
  delta.clear();
}
int main() {
  n = rint();
  for (int i = 1; i <= n; ++i) cost[i] = rint();
  for (int i = 1; i <= n; ++i) height[i] = rint();
  for (int i = 1, u, v; i < n; ++i) {
    u = rint(), v = rint();
    link(u, v), link(v, u);
  }
  solve(1, 0);
  wint(f[1][0]), putchar('\n');
  return 0;
}
