#include <bits/stdc++.h>
int Read() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
  return x;
}
const int MAXN = 200000;
int N;
int A[MAXN + 5], B[MAXN + 5];
std::vector<int> G[MAXN + 5];
long long Ans;
long long Dp[MAXN + 5][2];
void Dfs(int u, int f) {
  long long tot = 0;
  int out = 0, in = 0;
  std::vector<long long> num;
  for (int v : G[u]) {
    if (v != f) {
      Dfs(v, u);
      if (A[u] < A[v])
        tot += Dp[v][1], in++;
      else {
        tot += Dp[v][0], out++;
        if (A[u] == A[v]) num.push_back(Dp[v][1] - Dp[v][0]);
      }
    }
  }
  std::sort(num.begin(), num.end());
  Dp[u][0] = tot + (long long)B[u] * std::max(in + (u != 1), out);
  Dp[u][1] = tot + (long long)B[u] * std::max(in, out + (u != 1));
  for (int val : num) {
    in++, out--, tot += val;
    Dp[u][0] = std::min(Dp[u][0],
                        tot + (long long)B[u] * std::max(in + (u != 1), out));
    Dp[u][1] = std::min(Dp[u][1],
                        tot + (long long)B[u] * std::max(in, out + (u != 1)));
  }
}
int main() {
  N = Read();
  for (int i = 1; i <= N; i++) B[i] = Read();
  for (int i = 1; i <= N; i++) A[i] = Read();
  for (int i = 1; i < N; i++) {
    int u = Read(), v = Read();
    G[u].push_back(v);
    G[v].push_back(u);
  }
  Dfs(1, 0);
  printf("%lld", Dp[1][0]);
  return 0;
}
