#include <bits/stdc++.h>
using namespace std;
long long t[1000010], h[1000010], dp[1000010][3];
vector<long long> edg[1000010];
void dfs(long long u, long long p) {
  dp[u][0] = LLONG_MAX / 2, dp[u][1] = LLONG_MAX / 2, dp[u][2] = LLONG_MAX / 2;
  long long i = 0, o = 0, cur = 0;
  vector<long long> lis;
  for (auto&& v : edg[u])
    if (v != p) {
      dfs(v, u);
      if (h[v] > h[u]) {
        i++;
        cur += dp[v][1];
      } else if (h[v] < h[u]) {
        o++;
        cur += dp[v][0];
      } else {
        o++;
        cur += dp[v][0];
        lis.push_back(dp[v][1] - dp[v][0]);
      }
    }
  sort(lis.begin(), lis.end());
  dp[u][0] = min(dp[u][0], cur + t[u] * max(o, i + 1));
  dp[u][1] = min(dp[u][1], cur + t[u] * max(o + 1, i));
  dp[u][2] = min(dp[u][2], cur + t[u] * max(o, i));
  for (auto&& l : lis) {
    cur += l;
    i++;
    o--;
    dp[u][0] = min(dp[u][0], cur + t[u] * max(o, i + 1));
    dp[u][1] = min(dp[u][1], cur + t[u] * max(o + 1, i));
    dp[u][2] = min(dp[u][2], cur + t[u] * max(o, i));
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  for (long long i = 1; i < n + 1; i++) cin >> t[i];
  for (long long i = 1; i < n + 1; i++) cin >> h[i];
  for (long long i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    edg[a].push_back(b);
    edg[b].push_back(a);
  }
  dfs(1, -1);
  cout << dp[1][2] << endl;
}
