#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
const long long maxn = 2e5 + 10, maxm = 1e6 + 10, lg = 10, mod = 1e9 + 7,
                inf = 1e18;
long long n, dp[maxn][3], di[maxn], du[maxn], h[maxn], t[maxn];
vector<long long> g[maxn];
bool mk[maxn];
void dfs(long long v) {
  mk[v] = 1;
  long long sum = 0;
  vector<long long> vv;
  for (auto u : g[v])
    if (!mk[u]) {
      dfs(u);
      sum += dp[u][1];
      vv.push_back(dp[u][2] - dp[u][1]);
    }
  sort(vv.begin(), vv.end());
  for (int i = 0; i <= (long long)(vv.size()); i++) {
    for (int j : {0, 1, 2}) {
      long long din = di[v] + i + (j == 1),
                don = du[v] + ((long long)(vv.size()) - i) + (j == 2);
      dp[v][j] = min(dp[v][j], sum + t[v] * max(din, don));
    }
    if (i < (long long)(vv.size())) sum += vv[i];
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  memset(dp, 69, sizeof(dp));
  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; i++) {
    long long v, u;
    cin >> v >> u;
    if (h[v] == h[u])
      g[v].push_back(u), g[u].push_back(v);
    else {
      if (h[v] > h[u]) swap(v, u);
      du[v]++, di[u]++;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (!mk[i]) dfs(i), ans += dp[i][0];
  cout << ans;
  return 0;
}
