#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool d = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') d = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return d ? x : -x;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar('0' + x % 10);
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
inline void writep(long long x) {
  write(x);
  putchar(' ');
}
inline unsigned long long rnd() {
  return ((unsigned long long)rand() << 30 ^ rand()) << 4 | rand() % 4;
}
const int N = 2e5 + 5;
int a[N];
long long sum[N], cnt[N];
vector<long long> v[N];
long long dfs(int u) {
  long long mx = 0;
  sum[u] = a[u];
  for (auto k : v[u]) {
    mx = max(mx, dfs(k));
    sum[u] += sum[k];
    cnt[u] += cnt[k];
  }
  if (!v[u].size()) cnt[u] = 1;
  return max(mx, (sum[u] + cnt[u] - 1) / cnt[u]);
}
int main() {
  int n = read();
  for (int i = (int)(2); i <= (int)(n); i++) v[read()].push_back(i);
  for (int i = (int)(1); i <= (int)(n); i++) a[i] = read();
  cout << dfs(1);
}
