#include <bits/stdc++.h>
using namespace std;
long long a[200005], f[200005][2], now[200005], n, b[200005];
vector<long long> G[200005];
vector<long long> vc[200005];
void dfs(long long x, long long fa) {
  long long sum = 0, in = 0, out = 0;
  for (long long i = 0; i < G[x].size(); i++) {
    long long tmp = G[x][i];
    if (tmp != fa) {
      dfs(tmp, x);
      if (b[tmp] > b[x]) {
        in++;
        sum += f[tmp][1];
      }
      if (b[tmp] < b[x]) {
        out++;
        sum += f[tmp][0];
      }
      if (b[tmp] == b[x]) {
        out++;
        sum += f[tmp][0];
        vc[x].push_back(f[tmp][1] - f[tmp][0]);
      }
    }
  }
  sort(vc[x].begin(), vc[x].end());
  for (long long i = 0; i <= vc[x].size(); i++) {
    f[x][0] = min(f[x][0], sum + max(in + (x != 1), out) * a[x]);
    f[x][1] = min(f[x][1], sum + max(in, out + (x != 1)) * a[x]);
    in++, out--;
    if (i < vc[x].size()) sum += vc[x][i];
  }
}
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (long long i = 1; i <= n; i++) scanf("%lld", &b[i]);
  for (long long i = 1; i < n; i++) {
    long long u, v;
    scanf("%lld %lld", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  memset(f, 63, sizeof f);
  dfs(1, 0);
  printf("%lld\n", f[1][0]);
  return 0;
}
