#include <bits/stdc++.h>
const int MAXN = 200005;
const long long INF = (long long)1e18 + 8763;
using namespace std;
long long n, H[MAXN], T[MAXN], dp[MAXN][2];
vector<int> G[MAXN];
void dfs(int v, int p) {
  for (int &to : G[v]) {
    if (to == p) {
      swap(to, G[v].back());
      G[v].pop_back();
      break;
    }
  }
  long long must_in = 0, must_out = 0, sum = 0;
  vector<long long> rev;
  rev.push_back(0);
  for (int to : G[v]) {
    dfs(to, v);
    if (H[v] > H[to]) {
      must_in++;
      sum += dp[to][0];
    } else if (H[v] < H[to]) {
      must_out++;
      sum += dp[to][1];
    } else {
      sum += dp[to][0];
      rev.push_back(dp[to][1] - dp[to][0]);
    }
  }
  sort(rev.begin() + 1, rev.end(), less<long long>());
  for (int i = 1; i < rev.size(); i++) {
    rev[i] += rev[i - 1];
  }
  int rem = (int)rev.size() - 1;
  for (long long i = 0; i <= 1; i++) {
    dp[v][i] = INF;
    for (long long down = 0; down <= rem; down++) {
      long long in = must_in + (v != p && i == 1) + (rem - down);
      long long out = must_out + (v != p && i == 0) + down;
      long long cost = T[v] * max(in, out);
      dp[v][i] = min(dp[v][i], sum + rev[down] + cost);
    }
  }
}
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> T[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> H[i];
  }
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    G[v].push_back(u);
    G[u].push_back(v);
  }
  dfs(1, 1);
  cout << dp[1][0] << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tc = 1;
  for (int i = 1; i <= tc; i++) {
    solve();
  }
  return 0;
}
