#include <bits/stdc++.h>
using namespace std;
vector<long long int> gp[200100];
long long int a[200100], lf[200100], ans = 0;
void dfs(long long int i) {
  lf[i] = gp[i].empty();
  for (long long int j : gp[i]) {
    dfs(j);
    a[i] += a[j];
    lf[i] += lf[j];
  }
  ans = max(ans, (a[i] + lf[i] - 1) / lf[i]);
}
int main() {
  long long int n;
  cin >> n;
  long long int m;
  for (long long int i = 2; i <= n; i++) {
    cin >> m;
    gp[m].push_back(i);
  }
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  dfs(1);
  cout << ans << endl;
}
