#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
vector<int> e[N];
long long a[N];
int dfs(int u, long long& budget, long long lim) {
  if (e[u].empty()) {
    if (a[u] > lim) return 0;
    long long used = min(lim - a[u], budget);
    budget -= used;
    return 1;
  }
  long long oldBudget = budget;
  budget += a[u];
  for (int v : e[u]) {
    if (!dfs(v, budget, lim)) return 0;
  }
  if (budget > oldBudget) return 0;
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 2; i <= n; ++i) {
    int x;
    cin >> x;
    e[x].push_back(i);
  }
  for (int i = 1; i <= n; ++i) cin >> a[i];
  long long l = 0, r = 2e14, cur = 2e14;
  while (l <= r) {
    long long m = (l + r) >> 1;
    long long budget = 0;
    dfs(1, budget, m);
    if (!dfs(1, budget, m)) {
      l = m + 1;
    } else {
      cur = m;
      r = m - 1;
    }
  }
  cout << cur << '\n';
}
