#include <bits/stdc++.h>
using namespace std;
inline long long maxi(long long &a, long long b) {
  if (b > a) {
    a = b;
    return 1;
  }
  return 0;
}
inline long long mini(long long &a, long long b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
inline long long maxi(long double &a, long double b) {
  if (b > a) {
    a = b;
    return 1;
  }
  return 0;
}
inline long long mini(long double &a, long double b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const long long maxN = 2 * 1e5 + 1000;
long long a[maxN], d[maxN];
vector<long long> g[maxN];
void dfs(long long v, long long now = 1) {
  d[v] = now;
  for (long long to : g[v]) {
    dfs(to, now + 1);
  }
}
struct T {
  long long summ, sz, max;
  T() {
    summ = 0;
    sz = 0;
    max = 0;
  }
  T(long long summ, long long sz, long long max) {
    this->summ = summ;
    this->sz = sz;
    this->max = max;
  }
};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n;
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long p;
    cin >> p;
    p--;
    g[p].push_back(i);
  }
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  dfs(0);
  vector<pair<long long, long long> > hv;
  for (long long i = 0; i < n; i++) {
    hv.push_back({d[i], i});
  }
  sort(hv.rbegin(), hv.rend());
  vector<T> nodes(n);
  for (long long i = 0; i < n; i++) {
    if ((long long)g[i].size() == 0) {
      nodes[i] = T(a[i], 1, a[i]);
    }
  }
  for (long long i = 0; i < n; i++) {
    long long v = hv[i].second;
    if ((long long)g[v].size() == 0) {
      continue;
    }
    for (long long to : g[v]) {
      nodes[v].sz += nodes[to].sz;
      nodes[v].summ += nodes[to].summ;
      maxi(nodes[v].max, nodes[to].max);
    }
    long long need_ans = nodes[v].sz * nodes[v].max;
    if (need_ans - nodes[v].summ < a[v]) {
      long long extra = a[v] - (need_ans - nodes[v].summ);
      nodes[v].max += (extra + nodes[v].sz - 1) / nodes[v].sz;
    }
    nodes[v].summ += a[v];
  }
  cout << nodes[0].max;
}
