#include <bits/stdc++.h>
using namespace std;
vector<int> G[200005];
long long f[200005], a[200005];
long long aws;
long long l, r, mid;
int flag;
void io() { ios::sync_with_stdio(false); }
void dfs(int u) {
  if (!flag) return;
  a[u] = 0;
  if (G[u].empty()) {
    a[u] = mid - f[u];
    return;
  }
  for (int v : G[u]) {
    dfs(v);
    if (a[u] <= 1e17) a[u] += a[v];
  }
  a[u] -= f[u];
  if (a[u] < 0) flag = 0;
}
void solve() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int v;
    cin >> v;
    G[v].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    cin >> f[i];
    if (G[i].empty()) l = max(l, f[i]);
    r += f[i];
  }
  while (l <= r) {
    mid = (l + r) >> 1;
    flag = 1;
    dfs(1);
    if (flag) {
      r = mid - 1;
      aws = mid;
    } else
      l = mid + 1;
  }
  cout << aws;
}
int main() { solve(); }
