#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<int> tired(n);
  vector<int> height(n);
  vector<vector<int>> g(n);
  for (int i = 0; i < n; i++) {
    cin >> tired[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> height[i];
  }
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  const long long inf = 1e12;
  long long res = inf;
  function<pair<long long, long long>(int, int)> dfs = [&](int v, int par) {
    vector<pair<long long, long long>> cur;
    for (int i : g[v]) {
      if (i == par) continue;
      cur.push_back(dfs(i, v));
    }
    sort(cur.begin(), cur.end(),
         [&](pair<long long, long long> a, pair<long long, long long> b) {
           return a.second - a.first < b.second - b.first;
         });
    int sz = cur.size();
    pair<long long, long long> ans = make_pair(inf, inf);
    if (v) {
      long long sum = 0;
      for (auto i : cur) sum += i.first;
      for (int i = 0; i <= sz; i++) {
        int out = i;
        int in = sz - i;
        if (height[v] <= height[par])
          ans.first = min(ans.first, sum + 1LL * tired[v] * max(out + 1, in));
        if (height[v] >= height[par])
          ans.second = min(ans.second, sum + 1LL * tired[v] * max(in + 1, out));
        if (i < sz) sum += cur[i].second - cur[i].first;
      }
    } else {
      long long sum = 0;
      for (auto i : cur) sum += i.first;
      for (int i = 0; i <= sz; i++) {
        int out = i;
        int in = sz - i;
        res = min(res, sum + 1LL * tired[v] * max(in, out));
        if (i < sz) sum += cur[i].second - cur[i].first;
      }
    }
    return ans;
  };
  dfs(0, -1);
  cout << res;
  return 0;
}
