#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 9;
const long long mod = 998244353;
const long long Inf = 1e18;
int t[N], H[N], out[N], in[N];
long long f[N], h[N], a[N];
vector<int> g[N];
bool vis[N];
void dfs(int u, int fa) {
  vis[u] = true;
  for (int i = 0, v; i < g[u].size(); i++) {
    if ((v = g[u][i]) == fa) continue;
    dfs(v, u);
  }
  int s = 0;
  long long cur = 0;
  for (int i = 0, v; i < g[u].size(); i++) {
    if ((v = g[u][i]) == fa) continue;
    cur += h[v], a[++s] = f[v] - h[v];
  }
  sort(a + 1, a + s + 1);
  reverse(a + 1, a + s + 1);
  for (int i = 0; i <= s; i++) {
    cur += a[i];
    if (fa) {
      f[u] = max(f[u], 1ll * min(in[u] + 1 + s - i, out[u] + i) * t[u] + cur);
      h[u] = max(h[u], 1ll * min(in[u] + s - i, out[u] + 1 + i) * t[u] + cur);
    } else {
      f[u] = max(f[u], 1ll * min(in[u] + s - i, out[u] + i) * t[u] + cur);
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i < (n + 1); ++i) scanf("%d", &t[i]);
  for (int i = (1); i < (n + 1); ++i) scanf("%d", &H[i]);
  long long ans = 0;
  for (int i = (1); i < (n); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    ans += t[u] + t[v];
    if (H[u] == H[v]) {
      g[u].push_back(v);
      g[v].push_back(u);
    } else {
      if (H[u] > H[v]) swap(u, v);
      in[u]++;
      out[v]++;
    }
  }
  for (int i = (1); i < (n + 1); ++i) {
    if (!vis[i]) dfs(i, 0), ans -= f[i];
  }
  printf("%lld", ans);
}
