#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int llINF = 0x3f3f3f3f3f3f3f;
const int N = 2e5 + 1;
struct nd {
  long long int mx, diff, qnt;
};
vector<int> adj[N];
long long int arr[N];
nd dfs(int v) {
  bool end = true;
  nd cur;
  cur.mx = -1, cur.diff = 0, cur.qnt = 0;
  for (auto u : adj[v]) {
    end = false;
    if (cur.mx == -1) {
      cur = dfs(u);
    } else {
      nd plc = dfs(u);
      cur.diff = max(cur.mx, plc.mx) * (cur.qnt + plc.qnt) -
                 (cur.mx * cur.qnt - cur.diff) - (plc.mx * plc.qnt - plc.diff);
      cur.mx = max(cur.mx, plc.mx);
      cur.qnt += plc.qnt;
    }
  }
  if (end) {
    cur.mx = arr[v];
    cur.qnt = 1;
  } else {
    if (cur.diff > 0) {
      long long int vaca = min(cur.diff, arr[v]);
      arr[v] -= vaca;
      cur.diff -= vaca;
      if (arr[v] > 0) {
        cur.mx += arr[v] / cur.qnt + (arr[v] % cur.qnt > 0);
        if ((arr[v] % cur.qnt > 0)) {
          cur.diff = cur.qnt - arr[v] % cur.qnt;
        }
      }
    } else {
      if ((arr[v] % cur.qnt > 0)) cur.diff = cur.qnt - arr[v] % cur.qnt;
      cur.mx += arr[v] / cur.qnt + (arr[v] % cur.qnt > 0);
    }
  }
  return cur;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int a;
    scanf("%d", &a);
    adj[a - 1].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
  }
  printf("%lld\n", dfs(0).mx);
}
