#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,fma,mmx,avx,tune=native")
using namespace std;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
bool ldequal(long double a, long double b) { return abs(a - b) < 1e-9; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const int N = 2e5 + 1;
bool tests = false;
struct second {
  long long l, sm, mx;
};
long long arr[N];
vector<int> adj[N];
second dfs(int u, int p) {
  if ((int)adj[u].size() == 1 && adj[u][0] == p) {
    return second{1, arr[u], arr[u]};
  }
  second res = second{0, 0, 0};
  for (auto x : adj[u]) {
    if (x == p) continue;
    auto tmp = dfs(x, u);
    res.l += tmp.l;
    res.sm += tmp.sm;
    res.mx = max(res.mx, tmp.mx);
  }
  long long val = res.mx * (res.l - 1) - (res.sm - res.mx);
  if (val < arr[u]) {
    long long rem = arr[u] - val;
    res.mx += ceil(((long double)rem) / res.l);
  }
  res.sm += arr[u];
  ;
  return res;
}
void gen(){};
void solve() {
  int n, tmp;
  cin >> n;
  for (int i = 2; i < n + 1; i++) {
    cin >> tmp;
    adj[tmp].push_back(i);
    adj[i].push_back(tmp);
  }
  for (int i = 1; i < n + 1; i++) cin >> arr[i];
  auto res = dfs(1, 0);
  cout << res.mx;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  gen();
  long long test = 1;
  if (tests) cin >> test;
  for (int i = 1; i < test + 1; i++) {
    ;
    solve();
    cout << "\n";
  }
  return 0;
}
