#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > neib;
struct Square {
  long long max;
  long long diff;
  long long size;
};
vector<long long> a;
vector<Square> stat;
vector<int> color;
void dfs(int u) {
  color[u] = 1;
  stat[u].max += a[u];
  if (neib[u].size() == 1 && u != 0) {
    stat[u].max = a[u];
    stat[u].diff = 0;
    stat[u].size = 1;
    return;
  }
  for (auto to : neib[u]) {
    if (color[to] == 1) {
      continue;
    }
    dfs(to);
    stat[u].size += stat[to].size;
    stat[u].max += stat[to].max;
  }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  neib.resize(n);
  a.resize(n);
  stat.resize(n);
  color.resize(n, 0);
  for (long long i = 0; i < (long long)n - 1; i++) {
    int v;
    cin >> v;
    neib[i + 1].push_back(v - 1);
    neib[v - 1].push_back(i + 1);
  }
  for (long long i = 0; i < (long long)n; i++) {
    cin >> a[i];
  }
  if (n == 2) {
    cout << a[0] + a[1];
  } else {
    dfs(0);
    long long ans = -1;
    for (long long i = 0; i < (long long)n; i++) {
      long long t = (stat[i].max + stat[i].size - 1) / stat[i].size;
      ans = max(ans, t);
    }
    cout << ans;
  }
}
