#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long maxn = 1e6 + 100;
const long long inf = 1e16;
long long n, m, k, t;
long long A[maxn];
long long H[maxn];
vector<long long> V[maxn];
long long D[maxn][2];
bool cmp(long long i, long long j) {
  return D[i][0] - D[i][1] < D[j][0] - D[j][1];
}
void dfs(long long v, long long p) {
  vector<long long> X[3];
  for (auto v1 : V[v]) {
    if (v1 == p) {
      continue;
    }
    if (H[v1] == H[v]) {
      X[1].push_back(v1);
    }
    if (H[v1] < H[v]) {
      X[0].push_back(v1);
    }
    if (H[v1] > H[v]) {
      X[2].push_back(v1);
    }
    dfs(v1, v);
  }
  sort(X[1].begin(), X[1].end(), cmp);
  {
    long long sum = 0;
    for (auto first : X[0]) {
      sum += D[first][0];
    }
    for (auto first : X[1]) {
      sum += D[first][1];
    }
    for (auto first : X[2]) {
      sum += D[first][1];
    }
    D[v][0] = inf;
    long long cnt1 = X[0].size(), cnt2 = X[1].size() + X[2].size() + (v != p);
    long long dd = sum + max(cnt1, cnt2) * A[v];
    D[v][0] = min(D[v][0], dd);
    for (long long q = 0; q < X[1].size(); q++) {
      long long first = X[1][q];
      cnt2--;
      cnt1++;
      sum += (D[first][0] - D[first][1]);
      long long dd = sum + max(cnt1, cnt2) * A[v];
      D[v][0] = min(D[v][0], dd);
    }
  }
  {
    long long sum = 0;
    for (auto first : X[0]) {
      sum += D[first][0];
    }
    for (auto first : X[1]) {
      sum += D[first][1];
    }
    for (auto first : X[2]) {
      sum += D[first][1];
    }
    D[v][1] = inf;
    long long cnt1 = X[0].size() + (v != p), cnt2 = X[1].size() + X[2].size();
    long long dd = sum + max(cnt1, cnt2) * A[v];
    D[v][1] = min(D[v][1], dd);
    for (long long q = 0; q < X[1].size(); q++) {
      long long first = X[1][q];
      cnt2--;
      cnt1++;
      sum += (D[first][0] - D[first][1]);
      long long dd = sum + max(cnt1, cnt2) * A[v];
      D[v][1] = min(D[v][1], dd);
    }
  }
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long q, w, e, a, b, c;
  cin >> n;
  for (q = 0; q < n; q++) {
    cin >> A[q];
  }
  vector<long long> I;
  for (q = 0; q < n; q++) {
    cin >> H[q];
    I.push_back(H[q]);
  }
  sort(I.begin(), I.end());
  I.resize(unique(I.begin(), I.end()) - I.begin());
  for (q = 0; q < n; q++) {
    H[q] = lower_bound(I.begin(), I.end(), H[q]) - I.begin();
  }
  for (q = 0; q < n - 1; q++) {
    cin >> a >> b;
    a--;
    b--;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  dfs(0, 0);
  cout << min(D[0][0], D[0][1]);
  return 0;
}
