#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-6;
const int INF = 0x3fffffff;
const long long LINF = INF * 1ll * INF;
const double PI = acos(-1.0);
const int MAXN = 200005;
long long a[MAXN];
int p[MAXN];
int cnt[MAXN];
bool vis[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) cnt[i] = 1;
  p[1] = 0;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &p[i]);
    cnt[p[i]] = 0;
  }
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  queue<int> q;
  long long ans = -1;
  for (int i = n; i; i--) {
    ans = max(ans, a[i] / cnt[i] + (a[i] % cnt[i] ? 1 : 0));
    cnt[p[i]] += cnt[i];
    a[p[i]] += a[i];
  }
  printf("%lld\n", ans);
  return 0;
}
