#include <bits/stdc++.h>
using namespace std;
const long long int mxn = 2e5 + 5;
long long int p[mxn];
long long int a[mxn];
vector<long long int> to[mxn];
long long int val;
bool fine;
long long int ans;
pair<long long int, long long int> dfs(long long int u, long long int p = -1) {
  bool leaf = true;
  long long int leaves = 0, children = 0;
  for (long long int child : to[u]) {
    leaf = false;
    auto pr = dfs(child, u);
    leaves += pr.first;
    children += pr.second;
  }
  children += a[u];
  if (leaf) leaves++;
  long long int tmp = ceil(1.0 * (1.0 * children) / leaves);
  if (ans < tmp) {
    ans = tmp;
  }
  return {leaves, children};
}
void tc() {
  long long int n;
  cin >> n;
  long long int x;
  for (long long int i = 2; i < n + 1; i++) {
    cin >> x;
    p[i] = x;
    to[x].push_back(i);
  }
  for (long long int i = 1; i < n + 1; i++) cin >> a[i];
  p[1] = -1;
  long long int lo = 0, hi = 1e14;
  ans = -1e17;
  pair<long long int, long long int> pr = dfs(1);
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  t = 1;
  while (t--) tc();
}
