#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long inf_ll = 1e13;
const int N = 2e5 + 5;
long long t[N], h[N], dp[N][2];
vector<int> adj[N];
void dfs(int i, int p) {
  long long x = 0;
  vector<long long> d;
  for (auto& j : adj[i]) {
    if (j == p) continue;
    dfs(j, i);
    x += dp[j][0];
    d.push_back(dp[j][1] - dp[j][0]);
  }
  sort((d).begin(), (d).end());
  dp[i][0] = dp[i][1] = inf_ll;
  long long s = d.size();
  for (long long j = 0; j <= s; j++) {
    if (j > 0) x += d[j - 1];
    long long y = i == 0 ? 0 : 1;
    dp[i][0] = min(dp[i][0], x + t[i] * max(j + y, s - j));
    dp[i][1] = min(dp[i][1], x + t[i] * max(j, s - j + y));
  }
  if (i != 0 && h[i] < h[p]) dp[i][0] = inf_ll;
  if (i != 0 && h[i] > h[p]) dp[i][1] = inf_ll;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(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 = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    adj[x].push_back(y), adj[y].push_back(x);
  }
  dfs(0, -1);
  cout << dp[0][0] << "\n";
}
