#include <bits/stdc++.h>
using namespace std;
long long n;
vector<vector<long long>> g;
vector<long long> h, t;
vector<vector<long long>> dp;
void read() {
  cin >> n;
  h.assign(n, 0);
  t.assign(n, 0);
  g.assign(n, vector<long long>(0, 0));
  dp.assign(n, vector<long long>(2, 0));
  for (long long i = 0; i < n; i++) {
    cin >> t[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (long long i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
}
void dfs(long long v, long long p) {
  for (auto e : g[v]) {
    if (e == p) continue;
    dfs(e, v);
  }
  if (g[v].size() == 1 && v != 0) {
    dp[v][0] = t[v];
    dp[v][1] = t[v];
    return;
  }
  long long sum = 0;
  vector<long long> tek;
  long long a = 0, b = 0;
  for (auto e : g[v]) {
    if (e == p) continue;
    if (h[e] < h[v]) {
      sum += dp[e][1];
      a++;
    } else if (h[e] > h[v]) {
      sum += dp[e][0];
      b++;
    } else {
      sum += dp[e][0];
      b++;
      tek.push_back((long long)dp[e][1] - dp[e][0]);
    }
  }
  dp[v][1] = sum + (long long)t[v] * g[v].size();
  dp[v][0] = sum + (long long)t[v] * g[v].size();
  if (b == a) {
    dp[v][1] = min(dp[v][1], sum + t[v] * ((long long)g[v].size() - a));
    dp[v][0] = min(dp[v][0], sum + t[v] * ((long long)g[v].size() - a));
  } else if (a > b) {
    dp[v][1] = min(
        dp[v][1], sum + t[v] * ((long long)g[v].size() - min(a, b) - (v != 0)));
    dp[v][0] = min(dp[v][0], sum + t[v] * ((long long)g[v].size() - min(a, b)));
  } else {
    dp[v][0] = min(
        dp[v][0], sum + t[v] * ((long long)g[v].size() - min(a, b) - (v != 0)));
    dp[v][1] = min(dp[v][1], sum + t[v] * ((long long)g[v].size() - min(a, b)));
  }
  sort(tek.begin(), tek.end());
  for (long long i = 0; i < tek.size(); i++) {
    a++;
    b--;
    sum += tek[i];
    if (b == a) {
      dp[v][1] = min(dp[v][1], sum + t[v] * ((long long)g[v].size() - a));
      dp[v][0] = min(dp[v][0], sum + t[v] * ((long long)g[v].size() - a));
    } else if (a > b) {
      dp[v][1] = min(dp[v][1], sum + t[v] * ((long long)g[v].size() -
                                             min(a, b) - (v != 0)));
      dp[v][0] =
          min(dp[v][0], sum + t[v] * ((long long)g[v].size() - min(a, b)));
    } else {
      dp[v][0] = min(dp[v][0], sum + t[v] * ((long long)g[v].size() -
                                             min(a, b) - (v != 0)));
      dp[v][1] =
          min(dp[v][1], sum + t[v] * ((long long)g[v].size() - min(a, b)));
    }
  }
}
void solve() {
  dfs(0, -1);
  cout << min(dp[0][0], dp[0][1]) << "\n";
}
void write() {}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read();
  solve();
  write();
  return 0;
}
