#include <bits/stdc++.h>
using namespace std;
int const N = 200000;
long long const inf = 1e18;
int w[N + 1], h[N + 1];
long long dp[N + 1][2];
vector<int> tr[N + 1];
void up(long long &x, long long y) {
  if (y < x) x = y;
}
void fn(int v, vector<long long> const &ch, long long s, int in, int out,
        bool d) {
  for (int i = 0; i < (int)(ch.size() + 1); ++i) {
    if (i) {
      s += ch[i - 1];
      --out;
      ++in;
    }
    up(dp[v][d], s + (long long)w[v] * max(in, out));
  }
}
void go(int v = 1, int p = 0) {
  dp[v][0] = dp[v][1] = inf;
  vector<long long> ch;
  int in = 0, out = 0;
  long long s = 0;
  for (int u : tr[v])
    if (u != p) {
      go(u, v);
      if (dp[u][0] < inf) {
        ++out;
        s += dp[u][0];
        if (dp[u][1] < inf) ch.push_back(dp[u][1] - dp[u][0]);
      } else {
        ++in;
        s += dp[u][1];
      }
    }
  sort(ch.begin(), ch.end());
  if (p) {
    if (h[v] <= h[p]) fn(v, ch, s, in, out + 1, true);
    if (h[v] >= h[p]) fn(v, ch, s, in + 1, out, false);
  } else
    fn(v, ch, s, in, out, false);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < (int)(n + 1); ++i) scanf("%d", w + i);
  for (int i = 1; i < (int)(n + 1); ++i) scanf("%d", h + i);
  for (int i = 1; i < (int)(n); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    tr[a].push_back(b);
    tr[b].push_back(a);
  }
  go();
  printf("%lld\n", dp[1][0]);
}
