#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5;
vector<int> g[MAXN];
long long dp[MAXN][2];
long long t[MAXN];
long long h[MAXN];
void dfs(int cur, int par) {
  vector<int> deg(2, 0);
  vector<long long> a;
  long long sum = 0;
  for (int nx : g[cur]) {
    if (nx != par) {
      dfs(nx, cur);
      if (h[nx] > h[cur]) {
        deg[1]++;
        sum += dp[nx][0];
      } else if (h[nx] < h[cur]) {
        deg[0]++;
        sum += dp[nx][1];
      } else {
        a.push_back(dp[nx][1] - dp[nx][0]);
        sum += dp[nx][0];
        deg[1]++;
      }
    }
  }
  sort(a.begin(), a.end());
  auto calc = [&](int z) {
    vector<int> deg2 = deg;
    if (z != -1) deg2[z]++;
    long long res = max(deg2[0], deg2[1]) * t[cur] + sum;
    long long pre = 0;
    for (int i = 0; i < a.size(); i++) {
      pre += a[i];
      deg2[1]--;
      deg2[0]++;
      res = min(res, max(deg2[0], deg2[1]) * t[cur] + pre + sum);
    }
    return res;
  };
  if (par >= 0) {
    dp[cur][0] = calc(0);
    dp[cur][1] = calc(1);
  } else {
    cout << calc(-1) << "\n";
  }
}
void run_case() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> t[i];
  for (int i = 0; i < n; i++) cin >> h[i];
  for (int i = 0, u, v; i < n - 1; i++) {
    cin >> u >> v, u--, v--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  dfs(0, -1);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  if (fopen("input.in", "r"))
    freopen("input.in", "r", stdin), freopen("output.out", "w", stdout);
  int t;
  t = 1;
  while (t--) {
    run_case();
  }
}
