#include <bits/stdc++.h>
using namespace std;
const long long M = 200005;
long long read() {
  long long num = 0, flag = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = -1;
  while (c >= '0' && c <= '9')
    num = (num << 3) + (num << 1) + (c ^ 48), c = getchar();
  return num * flag;
}
long long n, tot, f[M], h[M], w[M], dp[M][2];
struct edge {
  long long v, next;
} e[2 * M];
void dfs(long long u, long long p) {
  long long sum = 0, a = 0, b = 0;
  vector<long long> q;
  for (long long i = f[u]; i; i = e[i].next) {
    long long v = e[i].v;
    if (v == p) continue;
    dfs(v, u);
    if (w[u] == w[v])
      q.push_back(dp[v][1] - dp[v][0]), sum += dp[v][0], a++;
    else if (w[u] > w[v])
      sum += dp[v][1], b++;
    else
      sum += dp[v][0], a++;
  }
  sort(q.begin(), q.end());
  for (long long i = 0; i <= q.size(); i++) {
    dp[u][0] = min(dp[u][0], sum + h[u] * max(a, b + (u != 1)));
    dp[u][1] = min(dp[u][1], sum + h[u] * max(a + (u != 1), b));
    a--;
    b++;
    if (i < q.size()) sum += q[i];
  }
}
signed main() {
  n = read();
  memset(dp, 0x3f, sizeof dp);
  for (long long i = 1; i <= n; i++) h[i] = read();
  for (long long i = 1; i <= n; i++) w[i] = read();
  for (long long i = 1; i < n; i++) {
    long long u = read(), v = read();
    e[++tot] = edge{v, f[u]}, f[u] = tot;
    e[++tot] = edge{u, f[v]}, f[v] = tot;
  }
  dfs(1, 0);
  printf("%lld\n", dp[1][0]);
}
