#include <bits/stdc++.h>
const long long N = 200010;
long long n, t[N], h[N], in[N], out[N], vis[N];
long long f[N], g[N];
long long a[N];
long long ans = 0;
std::vector<long long> G[N];
void dfs(long long now, long long pa) {
  vis[now] = 1;
  for (long long i : G[now]) {
    if (i == pa) continue;
    dfs(i, now);
  }
  long long cur = 0;
  long long tot = 0;
  for (long long i : G[now]) {
    if (i == pa) continue;
    cur += g[i];
    a[++tot] = f[i] - g[i];
  }
  std::sort(a + 1, a + tot + 1);
  std::reverse(a + 1, a + tot + 1);
  for (long long i = 0; i <= tot; ++i) {
    cur += a[i];
    if (pa) {
      f[now] = std::max(
          f[now], std::min(in[now] + tot - i + 1, out[now] + i) * t[now] + cur);
      g[now] = std::max(
          g[now], std::min(in[now] + tot - i, out[now] + i + 1) * t[now] + cur);
    } else {
      f[now] = std::max(
          f[now], std::min(in[now] + tot - i, out[now] + i) * t[now] + cur);
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cin >> n;
  for (long long i = 1; i <= n; ++i) std::cin >> t[i];
  for (long long i = 1; i <= n; ++i) std::cin >> h[i];
  for (long long i = 1; i < n; ++i) {
    long long x, y;
    std::cin >> x >> y;
    ans += t[x] + t[y];
    if (h[x] == h[y]) {
      G[x].push_back(y);
      G[y].push_back(x);
    } else {
      if (h[x] > h[y])
        in[x]++, out[y]++;
      else
        out[x]++, in[y]++;
    }
  }
  for (long long i = 1; i <= n; ++i) {
    if (!vis[i]) {
      dfs(i, 0);
      ans -= f[i];
    }
  }
  std::cout << ans << '\n';
  return 0;
}
