#include <bits/stdc++.h>
using namespace std;
using lli = long long;
using lld = long double;
using ulli = unsigned long long int;
using pll = pair<lli, lli>;
using ttt = pair<lli, pll>;
using vttt = vector<ttt>;
using vll = vector<pll>;
using vl = vector<lli>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using cd = complex<lld>;
const double PI = acos(-1);
lli tire[200010], height[200010];
lli in[200010], out[200010];
lli vtop[200010], ptov[200010];
bool vis[200010];
vvi adj(200010);
void process(lli arr[], int &v, lli &sum_ptov, vl &diff, int a, int b) {
  arr[v] = 0x3f3f3f3f3f3f3f3f;
  for (int tov = 0; tov < ((lli)(diff).size()); tov++) {
    lli contri =
        max(in[v] + a + tov, out[v] + b + ((lli)(diff).size()) - 1 - tov) *
        tire[v];
    contri += diff[tov] + sum_ptov;
    arr[v] = min(arr[v], contri);
  }
}
void dfs(int v, bool root = 0) {
  vis[v] = 1;
  vl diff(1, 0);
  lli sum_ptov = 0;
  for (auto &to : adj[v])
    if (!vis[to]) {
      dfs(to);
      diff.push_back(vtop[to] - ptov[to]);
      sum_ptov += ptov[to];
    }
  sort(diff.begin() + 1, diff.end());
  for (int i = 1; i < ((lli)(diff).size()); i++) diff[i] += diff[i - 1];
  if (root) {
    process(ptov, v, sum_ptov, diff, 0, 0);
  } else {
    process(ptov, v, sum_ptov, diff, 1, 0);
    process(vtop, v, sum_ptov, diff, 0, 1);
  }
}
int tejas_919(int kkkk) {
  lli n, m, k, q, u, v, temp = 0, ans = 0;
  cin >> n;
  for (int i = 1; i < n + 1; i++) cin >> tire[i];
  for (int i = 1; i < n + 1; i++) cin >> height[i];
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    if (height[u] == height[v]) {
      adj[u].push_back(v);
      adj[v].push_back(u);
    } else {
      if (height[u] > height[v]) swap(u, v);
      in[v]++;
      out[u]++;
    }
  }
  for (int v = 1; v < n + 1; v++)
    if (!vis[v]) {
      dfs(v, 1);
      ans += ptov[v];
    }
  cout << ans << '\n';
  return 0;
}
signed main() {
  if (!0) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  }
  cout << fixed << setprecision(10);
  int t = 1;
  for (int i = 0; i < t; i++) {
    tejas_919(i + 1);
  }
  {};
}
