#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 101;
int n, cost[N], h[N], in[N], out[N];
vector<int> G[N];
bool vis[N];
long long dp[N][2], ans;
void umax(long long &a, long long b) { a = max(a, b); }
void dfs(int v, int p = 0, bool root = true) {
  vis[v] = true;
  vector<long long> vals;
  long long a = 0;
  for (auto u : G[v]) {
    if (vis[u]) continue;
    dfs(u, v, false);
    a += dp[u][0];
    vals.push_back(dp[u][1] - dp[u][0]);
  }
  sort(vals.begin(), vals.end());
  vals.push_back(0);
  reverse(vals.begin(), vals.end());
  int sz = (int)vals.size() - 1;
  for (int i = 0; i <= (int)vals.size() - 1; ++i) {
    a += vals[i];
    int IN = in[v] + sz - i;
    int OUT = out[v] + i;
    int b = OUT - IN;
    long long val = 1LL * min(IN, OUT) * cost[v];
    a += val;
    if (b < 0) {
      umax(dp[v][0], a + (!root ? cost[v] : 0));
      umax(dp[v][1], a);
    }
    if (!b) {
      umax(dp[v][0], a);
      umax(dp[v][1], a);
    }
    if (b > 0) {
      umax(dp[v][1], a + (!root ? cost[v] : 0));
      umax(dp[v][0], a);
    }
    a -= val;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", cost + i);
  for (int i = 1; i <= n; ++i) scanf("%d", h + i);
  for (int i = 2; i <= n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    ans += cost[u] + cost[v];
    if (h[u] != h[v]) {
      if (h[u] > h[v]) swap(u, v);
      out[u]++;
      in[v]++;
    } else {
      G[u].push_back(v);
      G[v].push_back(u);
    }
  }
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      dfs(i);
      ans -= max(dp[i][0], dp[i][1]);
    }
  printf("%lld\n", ans);
  return 0;
}
