#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n;
const int dydis = 2e5 + 10;
long long kek[dydis];
__int128_t mn[dydis] = {0};
vector<int> gr[dydis];
bool dfs(int v, __int128_t &mx) {
  if (gr[v].size() == 0) {
    if (kek[v] > mx) return false;
    mn[v] = mx - kek[v];
    return 1;
  } else {
    __int128_t s = 0;
    bool ret = 1;
    for (auto x : gr[v]) {
      ret &= dfs(x, mx);
      s += mn[x];
    }
    if (s < kek[v]) ret = 0;
    mn[v] = s - kek[v];
    return ret;
  }
}
bool veikia(__int128_t mid) {
  for (int i = 0; i < n; i++) mn[i] = 0;
  return dfs(0, mid);
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    a--;
    gr[a].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    kek[i] = a;
  }
  long long l = 0, r = 2000000000000000, mid;
  long long ans = 2000000000000000;
  while (l <= r) {
    mid = (l + r) / 2ll;
    if (veikia(mid)) {
      ans = min(ans, mid);
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  cout << ans;
  return 0;
}
