#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
vector<vector<long long> > g;
vector<long long> a;
vector<bool> visited;
struct Node {
  long long maxim, rem, paths;
};
Node dfs(long long s) {
  Node fin = {0, 0, 0};
  vector<Node> nodes;
  for (int i = 0; i < g[s].size(); i++) {
    long long u = g[s][i];
    Node nd = dfs(u);
    nodes.push_back(nd);
  }
  for (int i = 0; i < nodes.size(); i++) {
    fin.maxim = max(fin.maxim, nodes[i].maxim);
  }
  for (int i = 0; i < nodes.size(); i++) {
    fin.paths += nodes[i].paths;
    fin.rem += nodes[i].rem;
    fin.rem += (fin.maxim - nodes[i].maxim) * nodes[i].paths;
  }
  if (fin.paths == 0) fin.paths = 1;
  if (fin.rem >= a[s]) {
    fin.rem -= a[s];
  } else {
    a[s] -= fin.rem;
    fin.rem = 0;
    fin.maxim += a[s] / fin.paths + ((a[s] % fin.paths) > 0);
    fin.rem = (fin.paths - a[s] % fin.paths) % fin.paths;
  }
  return fin;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  g = vector<vector<long long> >(n + 1);
  a = vector<long long>(n + 1);
  visited = vector<bool>(n + 1, false);
  for (int i = 2; i <= n; i++) {
    long long pi;
    cin >> pi;
    g[pi].push_back(i);
  }
  for (int i = 1; i <= n; i++) cin >> a[i];
  cout << dfs(1).maxim << "\n";
  return 0;
}
