#include <bits/stdc++.h>
using namespace std;
struct __timestamper {};
vector<int> t, h;
vector<vector<int>> g;
vector<long long> dp[3];
long long calc(int v, int p, int out) {
  long long& ans = dp[out][v];
  if (ans != -1) {
    return ans;
  }
  if (p == -1 && out != 1) {
    return -1;
  }
  if (p != -1 && out == 1) {
    return -1;
  }
  if (p != -1 && out == 0 && h[v] < h[p]) {
    return -1;
  }
  if (p != -1 && out == 2 && h[v] > h[p]) {
    return -1;
  }
  ans = numeric_limits<long long>::max();
  long long cur = 0;
  vector<long long> changes;
  int cnt0 = (out == 0), cnt2 = (out == 2);
  for (int u : g[v]) {
    if (u == p) continue;
    long long ans0 = calc(u, v, 2);
    long long ans2 = calc(u, v, 0);
    if (ans0 == -1) {
      cur += ans2;
      cnt2++;
    } else {
      cur += ans0;
      cnt0++;
      if (ans2 != -1) {
        changes.push_back(ans2 - ans0);
      }
    }
  }
  sort(changes.begin(), changes.end());
  for (int i = 0; i <= (int)changes.size(); i++) {
    ans = min(ans, cur + max(cnt0, cnt2) * 1LL * t[v]);
    if (i != (int)changes.size()) {
      cnt0--;
      cnt2++;
      cur += changes[i];
    }
  };
  return ans;
}
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    t = vector<int>(n);
    h = vector<int>(n);
    g = vector<vector<int>>(n);
    dp[0] = dp[1] = dp[2] = vector<long long>(n, -1);
    for (int i = 0; i < n; i++) {
      scanf("%d", &t[i]);
    }
    for (int i = 0; i < n; i++) {
      scanf("%d", &h[i]);
    }
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      --a, --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    printf("%lld\n", calc(0, -1, 1));
  }
  return 0;
}
