#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void ckmax(T& x, T y) {
  x = (y > x ? y : x);
}
template <typename T>
inline void ckmin(T& x, T y) {
  x = (y < x ? y : x);
}
namespace Fread {
const int SIZE = 1 << 21;
char buf[SIZE], *S, *T;
inline char getchar() {
  if (S == T) {
    T = (S = buf) + fread(buf, 1, SIZE, stdin);
    if (S == T) return EOF;
  }
  return *S++;
}
}  // namespace Fread
namespace Fwrite {
const int SIZE = 1 << 21;
char buf[SIZE], *S = buf, *T = buf + SIZE;
inline void flush() {
  fwrite(buf, 1, S - buf, stdout);
  S = buf;
}
inline void putchar(char c) {
  *S++ = c;
  if (S == T) flush();
}
struct NTR {
  ~NTR() { flush(); }
} ztr;
}  // namespace Fwrite
namespace Fastio {
struct Reader {
  template <typename T>
  Reader& operator>>(T& x) {
    char c = Fread ::getchar();
    T f = 1;
    while (c < '0' || c > '9') {
      if (c == '-') f = -1;
      c = Fread ::getchar();
    }
    x = 0;
    while (c >= '0' && c <= '9') {
      x = x * 10 + (c - '0');
      c = Fread ::getchar();
    }
    x *= f;
    return *this;
  }
  Reader& operator>>(char& c) {
    c = Fread ::getchar();
    while (c == '\n' || c == ' ') c = Fread ::getchar();
    return *this;
  }
  Reader& operator>>(char* str) {
    int len = 0;
    char c = Fread ::getchar();
    while (c == '\n' || c == ' ') c = Fread ::getchar();
    while (c != '\n' && c != ' ') {
      str[len++] = c;
      c = Fread ::getchar();
    }
    str[len] = '\0';
    return *this;
  }
  Reader() {}
} cin;
const char endl = '\n';
struct Writer {
  template <typename T>
  Writer& operator<<(T x) {
    if (x == 0) {
      Fwrite ::putchar('0');
      return *this;
    }
    if (x < 0) {
      Fwrite ::putchar('-');
      x = -x;
    }
    static int sta[45];
    int top = 0;
    while (x) {
      sta[++top] = x % 10;
      x /= 10;
    }
    while (top) {
      Fwrite ::putchar(sta[top] + '0');
      --top;
    }
    return *this;
  }
  Writer& operator<<(char c) {
    Fwrite ::putchar(c);
    return *this;
  }
  Writer& operator<<(char* str) {
    int cur = 0;
    while (str[cur]) Fwrite ::putchar(str[cur++]);
    return *this;
  }
  Writer& operator<<(const char* str) {
    int cur = 0;
    while (str[cur]) Fwrite ::putchar(str[cur++]);
    return *this;
  }
  Writer() {}
} cout;
}  // namespace Fastio
const int MAXN = 2e5;
int n, tired[MAXN + 5], hight[MAXN + 5];
long long dp[MAXN + 5][2];
vector<int> G[MAXN + 5];
vector<pair<long long, int> > eq[MAXN + 5];
void dfs(int u, int fa) {
  long long sum_le = 0, sum_gr = 0;
  int cnt_le = 0, cnt_gr = 0;
  for (int i = 0; i < ((int)(G[u]).size()); ++i) {
    int v = G[u][i];
    if (v == fa) continue;
    dfs(v, u);
    if (hight[v] < hight[u]) {
      cnt_le++;
      sum_le += dp[v][0];
    } else if (hight[v] > hight[u]) {
      cnt_gr++;
      sum_gr += dp[v][1];
    } else {
      eq[u].push_back(make_pair(dp[v][0] - dp[v][1], v));
    }
  }
  if (cnt_le <= cnt_gr) {
    long long sum = sum_le + sum_gr + (long long)cnt_le * tired[u];
    int rest = cnt_gr - cnt_le;
    sort(eq[u].begin(), eq[u].end());
    reverse(eq[u].begin(), eq[u].end());
    long long eqcur = 0;
    for (int i = 0; i < ((int)(eq[u]).size()); ++i)
      eqcur += dp[eq[u][i].second][1];
    ckmax(dp[u][0], sum + eqcur);
    ckmax(
        dp[u][1],
        sum + eqcur + (u != 1 && rest + ((int)(eq[u]).size()) > 0) * tired[u]);
    for (int i = 1; i <= ((int)(eq[u]).size()); ++i) {
      eqcur += eq[u][i - 1].first;
      int mat = 0, have_0 = 0, have_1 = 0;
      if (i <= rest) {
        mat = i;
        have_1 = (i < rest || i < ((int)(eq[u]).size()));
      } else {
        mat = rest + min(i - rest, ((int)(eq[u]).size()) - i);
        have_0 = (i - rest > ((int)(eq[u]).size()) - i);
        have_1 = (i - rest < ((int)(eq[u]).size()) - i);
      }
      if (u == 1) have_0 = have_1 = 0;
      ckmax(dp[u][0], sum + eqcur + (long long)(mat + have_0) * tired[u]);
      ckmax(dp[u][1], sum + eqcur + (long long)(mat + have_1) * tired[u]);
    }
  } else {
    long long sum = sum_le + sum_gr + (long long)cnt_gr * tired[u];
    int rest = cnt_le - cnt_gr;
    sort(eq[u].begin(), eq[u].end());
    long long eqcur = 0;
    for (int i = 0; i < ((int)(eq[u]).size()); ++i)
      eqcur += dp[eq[u][i].second][0];
    ckmax(
        dp[u][0],
        sum + eqcur + (u != 1 && rest + ((int)(eq[u]).size()) > 0) * tired[u]);
    ckmax(dp[u][1], sum + eqcur);
    for (int i = 1; i <= ((int)(eq[u]).size()); ++i) {
      eqcur -= eq[u][i - 1].first;
      int mat = 0, have_0 = 0, have_1 = 0;
      if (i <= rest) {
        mat = i;
        have_0 = (i < rest || i < ((int)(eq[u]).size()));
      } else {
        mat = rest + min(i - rest, ((int)(eq[u]).size()) - i);
        have_0 = (i - rest < ((int)(eq[u]).size()) - i);
        have_1 = (i - rest > ((int)(eq[u]).size()) - i);
      }
      if (u == 1) have_0 = have_1 = 0;
      ckmax(dp[u][0], sum + eqcur + (long long)(mat + have_0) * tired[u]);
      ckmax(dp[u][1], sum + eqcur + (long long)(mat + have_1) * tired[u]);
    }
  }
}
int main() {
  Fastio ::cin >> n;
  for (int i = 1; i <= n; ++i) Fastio ::cin >> tired[i];
  for (int i = 1; i <= n; ++i) Fastio ::cin >> hight[i];
  for (int i = 1; i < n; ++i) {
    int u, v;
    Fastio ::cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, 0);
  long long ans = 0;
  for (int i = 1; i <= n; ++i)
    ans += (long long)tired[i] * ((int)(G[i]).size());
  assert(dp[1][0] == dp[1][1]);
  ans -= dp[1][0];
  Fastio ::cout << ans << Fastio ::endl;
  return 0;
}
