#include <bits/stdc++.h>
using namespace std;
void no() { cout << "no" << '\n'; }
void NO() { cout << "NO" << '\n'; }
void yes() { cout << "yes" << '\n'; }
void YES() { cout << "YES" << '\n'; }
void imp() { cout << "-1" << '\n'; }
const int inf = 0x3f3f3f3f;
const long long infl = 0x3f3f3f3f3f3f3f3f;
struct edgegraph {
  int n, ecnt = 0;
  vector<int> from, to;
  vector<vector<int>> edg;
  edgegraph(int n) : n(n), edg(n) {}
  void add(int a, int b) {
    from.push_back(a);
    to.push_back(b);
    edg[a].push_back(ecnt++);
  }
};
template <typename T>
vector<int> iota(vector<T> &a, bool greater = false) {
  vector<int> res(a.size());
  iota(res.begin(), res.end(), 0);
  sort(res.begin(), res.end(), [&](int i, int j) {
    if (greater) return a[i] > a[j];
    return a[i] < a[j];
  });
  return res;
}
void solve() {
  int n;
  cin >> n;
  edgegraph g(n);
  for (int i = 2; i <= (n); i++) {
    int p;
    cin >> p;
    g.add(p - 1, i - 1);
  }
  vector<long long> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  vector<long long> leaves(n), mx(n), cap(n);
  function<void(int, int)> dfs = [&](int u, int p) {
    if (g.edg[u].empty()) {
      leaves[u] = 1;
      mx[u] = a[u];
      cap[u] = 0;
      return;
    }
    long long tmx = 0, tcap = 0;
    for (int nxe : g.edg[u]) {
      int v = g.to[nxe];
      if (v == p) continue;
      dfs(v, u);
      tmx = max(tmx, mx[v]);
      leaves[u] += leaves[v];
    }
    for (int nxe : g.edg[u]) {
      int v = g.to[nxe];
      if (v == p) continue;
      tcap += cap[v] + 1LL * (tmx - mx[v]) * leaves[v];
    }
    if (tcap >= a[u]) {
      cap[u] = tcap - a[u];
      mx[u] = tmx;
    } else {
      long long over = a[u] - tcap;
      mx[u] = tmx + (over + leaves[u] - 1) / leaves[u];
      long long rest = over % leaves[u];
      cap[u] = (rest == 0) ? 0 : (leaves[u] - rest);
    }
  };
  dfs(0, -1);
  cout << mx[0] << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tc = 1;
  while (tc--) solve();
  return 0;
}
