#include <bits/stdc++.h>
using namespace std;
vector<int> g[200005];
long long val[200005];
long long ans = 0LL;
pair<long long, long long> dfs(int v) {
  long long child = 0;
  long long sum = val[v];
  for (auto it : g[v]) {
    pair<long long, long long> xx = dfs(it);
    sum += xx.first;
    child += xx.second;
  }
  if (child == 0) child++;
  long long yy = sum / child;
  if (sum % child != 0) yy++;
  ans = max(ans, yy);
  return {yy, child};
}
int main() {
  int n, i, j;
  cin >> n;
  for (i = 2; i <= n; i++) {
    int u;
    cin >> u;
    g[u].push_back(i);
  }
  val[0] = 0;
  long long sm = 0;
  for (i = 1; i <= n; i++) {
    cin >> val[i];
    sm += val[i];
  }
  pair<long long, long long> yy = dfs(1);
  long long xx = ceil(sm * 1.0 / yy.second);
  cout << max(ans, xx);
  printf("\n");
  return 0;
}
