#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
__int128 a[N], mx, b[N];
vector<int> to[N];
int d[N];
int n;
vector<int> ye;
int flag;
void dfs(int u) {
  if (!flag) return;
  __int128 now = b[u];
  for (auto v : to[u]) {
    dfs(v);
    now += b[v];
  }
  if (!flag) return;
  if (now < a[u]) {
    flag = 0;
    return;
  }
  b[u] = now - a[u];
}
bool check(__int128 m) {
  if (m < mx) return false;
  for (int i = 1; i <= n; i++) b[i] = 0;
  for (auto v : ye) b[v] = m;
  flag = 1;
  dfs(1);
  return flag;
}
inline __int128 in() {
  char c = 0;
  __int128 x = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + (c - '0'), c = getchar();
  return x;
}
void write(__int128 x) {
  if (x < 10) {
    putchar(x + '0');
    return;
  }
  write(x / 10);
  putchar(x % 10 + '0');
}
int main() {
  scanf("%d", &n);
  __int128 sum = 0;
  for (int i = 2; i <= n; i++) {
    int y;
    scanf("%d", &y);
    to[y].push_back(i);
    d[y]++;
  }
  mx = -1;
  for (int i = 1; i <= n; i++) {
    a[i] = in();
    sum += a[i];
    if (d[i] == 0) {
      mx = max(mx, a[i]);
      ye.push_back(i);
    }
  }
  __int128 l = 0, r = sum, ans;
  while (l <= r) {
    __int128 mid = (l + r) / 2;
    if (check(mid)) {
      r = mid - 1;
      ans = mid;
    } else {
      l = mid + 1;
    }
  }
  write(ans);
  return 0;
}
