#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int N = 200005;
map<long long, int> mp[N];
int pos[N], a[N], p[N], deg[N];
int merge(int i, int j) {
  if (mp[i].size() < mp[j].size()) swap(i, j);
  if (mp[j].size() == 0) return i;
  for (auto &p : mp[j]) {
    mp[i][p.first] += p.second;
  }
  mp[j].clear();
  return i;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", p + i);
    deg[p[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    pos[i] = i;
    if (deg[i] == 0) mp[i][0] = 1;
  }
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = n; i >= 1; i--) {
    long long rem = a[i];
    while (mp[pos[i]].size() > 1) {
      auto it = mp[pos[i]].begin();
      auto nx = it;
      ++nx;
      long long dif = (nx->first) - (it->first);
      long long can = rem / dif;
      if (can < it->second) break;
      rem -= dif * (it->second);
      nx->second += it->second;
      auto save = it;
      it = nx;
      mp[pos[i]].erase(save);
    }
    if (rem) {
      auto it = mp[pos[i]].begin();
      long long num = it->second;
      long long val = it->first;
      mp[pos[i]].erase(it);
      long long add = rem / num;
      long long red = rem % num;
      if (red) {
        mp[pos[i]][val + add + 1] += red;
      }
      if (red < num) {
        mp[pos[i]][val + add] += num - red;
      }
    }
    int pa = p[i];
    if (pa) {
      pos[pa] = merge(pos[pa], pos[i]);
    }
  }
  printf("%lld\n", mp[pos[1]].rbegin()->first);
}
