#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 5;
const int M = 3e4 + 5;
const long long INF = (long long)(1e18);
const int inf = 2e9;
const long long MOD = 1000000007LL;
struct Info {
  long long maxi;
  long long leaves;
  long long sum;
};
int n;
vector<int> G[MAX_N];
long long a[MAX_N];
Info dfs(int v) {
  if (G[v].empty()) return {a[v], 1LL, a[v]};
  long long toSplit = a[v];
  Info res = {0LL, 0LL, a[v]};
  long long childrenSum = 0LL;
  for (int to : G[v]) {
    Info child = dfs(to);
    childrenSum += child.sum;
    long long total = child.maxi * child.leaves;
    long long toEqual = min(toSplit, total - child.sum);
    toSplit -= toEqual;
    childrenSum += toEqual;
    res.leaves += child.leaves;
    res.sum += child.sum;
    res.maxi = max(res.maxi, child.maxi);
  }
  long long total = res.maxi * res.leaves;
  long long toEqual = total - childrenSum;
  if (toSplit > toEqual) {
    toSplit -= toEqual;
    long long tmp = (toSplit + res.leaves - 1) / res.leaves;
    res.maxi += tmp;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int p;
    cin >> p;
    G[p].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  Info ans = dfs(1);
  cout << ans.maxi << '\n';
  return 0;
}
