#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 99;
const long long inf = 1e13;
int n, u, v, t[N], h[N];
long long ans, dp0[N], dp1[N];
vector<int> g[N];
void dfs(int x, int par) {
  long long sum = 0;
  vector<long long> e, v;
  v.push_back(0);
  dp0[x] = dp1[x] = inf;
  for (int i = 0; i < g[x].size(); i++)
    if (g[x][i] != par) {
      dfs(g[x][i], x);
      sum += dp0[g[x][i]];
      e.push_back(dp0[g[x][i]] - dp1[g[x][i]]);
    }
  sort(e.begin(), e.end());
  reverse(e.begin(), e.end());
  for (int i = 0; i < e.size(); i++) v.push_back(e[i]);
  for (int i = 0; i < v.size(); i++) {
    if (i) v[i] += v[i - 1];
    if (1 < x) {
      dp0[x] = min(dp0[x],
                   sum - v[i] + 1ll * max(i + 1, int(v.size()) - 1 - i) * t[x]);
      ;
      dp1[x] = min(dp1[x], sum - v[i] + 1ll * max(i, int(v.size()) - i) * t[x]);
      ;
    } else
      dp0[x] =
          min(dp0[x], sum - v[i] + 1ll * max(i, int(v.size()) - 1 - i) * t[x]);
  }
  if (h[x] < h[par]) dp0[x] = inf;
  if (h[par] < h[x]) dp1[x] = inf;
}
int main() {
  cin >> n;
  for (int i = 1; i < n + 1; i++) scanf("%d", &t[i]);
  ;
  for (int i = 1; i < n + 1; i++) scanf("%d", &h[i]);
  ;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    ;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0);
  cout << dp0[1];
}
