#include <bits/stdc++.h>
using namespace std;
int t[200005];
int h[200005];
vector<int> v[200005];
int vis[200005];
long long dp[200005][2];
long long val;
void dfs(int first, int f) {
  vis[first] = 1;
  long long in = 0, out = 0;
  vector<long long> vv;
  long long sum = 0;
  for (auto it : v[first]) {
    if (it != f) {
      if (h[it] > h[first])
        out++;
      else if (h[it] < h[first])
        in++;
      else {
        dfs(it, first);
        sum += dp[it][0];
        in++;
        vv.push_back(dp[it][1] - dp[it][0]);
      }
    }
  }
  sort(vv.begin(), vv.end());
  val = sum + max(in, out) * t[first];
  dp[first][0] = sum + max(in, out + 1) * t[first];
  dp[first][1] = sum + max(in + 1, out) * t[first];
  for (auto it : vv) {
    sum += it;
    in--;
    out++;
    val = min(val, sum + max(in, out) * t[first]);
    dp[first][0] = min(dp[first][0], sum + max(in, out + 1) * t[first]);
    dp[first][1] = min(dp[first][1], sum + max(in + 1, out) * t[first]);
  }
}
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &h[i]);
  }
  for (int i = 1; i < n; i++) {
    int first, second;
    scanf("%d %d", &first, &second);
    v[first].push_back(second);
    v[second].push_back(first);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i, 0);
      ans += val;
    }
  }
  printf("%lld\n", ans);
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
