#include <bits/stdc++.h>
const int maxn = 2e5 + 5;
using namespace std;
int n, t[maxn], h[maxn], in[maxn], out[maxn], vis[maxn];
vector<int> tr[maxn];
long long ans, f[maxn], g[maxn], a[maxn];
void dfs(int u, int fa) {
  vis[u] = 1;
  for (int i = 0; i < tr[u].size(); i++) {
    int v = tr[u][i];
    if (v == fa) continue;
    dfs(v, u);
  }
  int s = 0;
  long long cur = 0;
  for (int i = 0; i < tr[u].size(); i++) {
    int v = tr[u][i];
    if (v == fa) continue;
    cur += g[v];
    a[++s] = f[v] - g[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] + s - i + 1, out[u] + i) * t[u] + cur);
      g[u] = max(g[u], 1LL * min(in[u] + s - i, out[u] + i + 1) * t[u] + cur);
    } else {
      f[u] = max(f[u], 1LL * min(in[u] + s - i, out[u] + i) * t[u] + cur);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
  for (int u, v, i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    ans += t[u] + t[v];
    if (h[u] == h[v])
      tr[u].push_back(v), tr[v].push_back(u);
    else {
      if (h[u] > h[v]) swap(u, v);
      in[u]++;
      out[v]++;
    }
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0), ans -= f[i];
  printf("%I64d\n", ans);
  return 0;
}
