#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
vector<int> G[200005];
long long t[200005], h[200005], dp[200005][2];
void dfs(int x, int p) {
  int c0 = 0, c1 = 0;
  vector<long long> tmp;
  long long res = 0;
  for (int i : G[x]) {
    if (i == p) continue;
    dfs(i, x);
    if (h[i] < h[x]) {
      res += dp[i][0];
      c0++;
    } else if (h[i] > h[x]) {
      res += dp[i][1];
      c1++;
    } else {
      res += dp[i][0];
      tmp.push_back(dp[i][1] - dp[i][0]);
    }
  }
  int k = min(c0, c1);
  c0 -= k;
  c1 -= k;
  res += t[x] * k;
  if (tmp.empty()) {
    res += t[x] * max(c0, c1);
    dp[x][0] = res + (c0 || !x ? 0 : t[x]);
    dp[x][1] = res + (c1 || !x ? 0 : t[x]);
  } else {
    sort(tmp.begin(), tmp.end());
    dp[x][0] = dp[x][1] = 1e18;
    long long s = 0;
    for (int i = 0; i <= (int)tmp.size(); i++) {
      if (i) s += tmp[i - 1];
      int t0 = c0 + ((int)tmp.size() - i), t1 = c1 + i;
      int k = min(t0, t1);
      t0 -= k;
      t1 -= k;
      dp[x][0] =
          min(dp[x][0], res + s + (k + t0 + t1) * t[x] + (t0 || !x ? 0 : t[x]));
      dp[x][1] =
          min(dp[x][1], res + s + (k + t0 + t1) * t[x] + (t1 || !x ? 0 : t[x]));
    }
  }
}
int main() {
  cin.tie(0), ios::sync_with_stdio(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];
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    G[u - 1].push_back(v - 1);
    G[v - 1].push_back(u - 1);
  }
  dfs(0, 0);
  cout << min(dp[0][0], dp[0][1]) << "\n";
  return 0;
}
