#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
#pragma GCC optimize("03")
using namespace std;
long long t[(long long)(2e5 + 5)];
long long h[(long long)(2e5 + 5)];
long long ts[(long long)(2e5 + 5)][2];
long long dp[(long long)(2e5 + 5)][3];
bool mk[(long long)(2e5 + 5)];
vector<int> g[(long long)(2e5 + 5)];
void dfs(int u) {
  mk[u] = 1;
  vector<long long> sons;
  long long sum = 0;
  for (auto v : g[u]) {
    if (mk[v]) continue;
    dfs(v);
    sons.push_back(dp[v][0] - dp[v][1]);
    sum += dp[v][0];
  }
  sort((sons).begin(), (sons).end());
  for (int i = 0; i < 3; i++) {
    if (i < 2) ts[u][i]++;
    long long act = sum;
    ts[u][1] += sons.size();
    dp[u][i] = act + (min(ts[u][0], ts[u][1]) * t[u]);
    for (auto y : sons) {
      act -= y;
      ts[u][1]--;
      ts[u][0]++;
      dp[u][i] = max(act + (min(ts[u][0], ts[u][1]) * t[u]), dp[u][i]);
    }
    ts[u][0] -= sons.size();
    if (i < 2) ts[u][i]--;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> t[i];
  for (int i = 0; i < n; i++) cin >> h[i];
  long long sum = 0;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    sum += t[u] + t[v];
    if (h[u] != h[v]) {
      if (h[u] > h[v]) {
        ts[u][0]++;
        ts[v][1]++;
      } else {
        ts[u][1]++;
        ts[v][0]++;
      }
    } else {
      g[u].push_back(v);
      g[v].push_back(u);
    }
  }
  for (int i = 0; i < n; i++) {
    if (mk[i]) continue;
    dfs(i);
    sum -= dp[i][2];
  }
  cout << (sum) << '\n';
  return 0;
}
