#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long n, p[N], a[N];
vector<long long> v[N];
long long t1[N], t2[N];
long long maxi = 0;
void dfs(long long x) {
  long long sz = v[x].size();
  t2[x] += a[x];
  if (sz == 0) {
    t1[x] = 1;
  }
  for (long long i = 0; i < sz; i++) {
    dfs(v[x][i]);
    t2[x] += t2[v[x][i]];
    t1[x] += t1[v[x][i]];
  }
  maxi = max(maxi, (t2[x] + t1[x] - 1) / t1[x]);
}
int32_t main() {
  cin >> n;
  for (long long i = 2; i <= n; i++) {
    cin >> p[i];
    v[p[i]].push_back(i);
  }
  for (long long i = 1; i <= n; i++) cin >> a[i];
  dfs(1);
  cout << maxi << endl;
}
