#include <bits/stdc++.h>
using namespace std;
long long n, Head[500010], Next[500010], Go[500010], Val[500010], Deg[500010],
    L[500010], R[500010], V[500010], F[500010][2], vis[500010], Ans[500010], T,
    Cnt = 0, St = 0;
vector<pair<long long, long long> > Sm[500010], G[500010];
bool cmp(long long first, long long second) { return Deg[first] > Deg[second]; }
bool cmpP(pair<long long, long long> first, pair<long long, long long> second) {
  return Deg[first.first] > Deg[second.first];
}
long long getpre(vector<pair<long long, long long> > &A1,
                 vector<pair<long long, long long> > &V, long long v) {
  for (long long tot = 0, s = 0, i = 0, nxt; i + 1 < V.size(); i = nxt) {
    for (nxt = i; nxt < V.size(); nxt++) {
      if (V[nxt].first >= 0 && V[nxt].first != V[i].first) break;
      tot += V[nxt].first * V[nxt].second, s += V[nxt].second;
    }
    long long t = lower_bound(A1.begin(), A1.end(),
                              pair<long long, long long>(V[nxt].first, -1e18)) -
                  A1.begin();
    long long w = lower_bound(A1.begin(), A1.end(),
                              pair<long long, long long>(V[i].first, -1e18)) -
                  A1.begin();
    if (t + s >= v) {
      t = max(v - s, w);
      return (t ? A1[t - 1].second : 0) + tot -
             (s + t - v) * max(V[i].first, 0ll);
    }
  }
  return 1e12;
}
void DFS(long long first, long long f) {
  vector<pair<long long, long long> > V(1, pair<long long, long long>(-1, 0));
  vis[first] = T + 1, V.push_back(pair<long long, long long>(0, 0)),
  V.push_back(pair<long long, long long>(1e12, 0));
  long long tot = 0, fv = 0;
  for (long long i = 0, g = G[first][0].first;
       i < G[first].size() && Deg[g = G[first][i].first] > T; i++) {
    V.push_back(pair<long long, long long>(G[first][i].second, -1));
    if (g != f)
      DFS(G[first][i].first, first), tot += F[g][0],
          V.push_back(pair<long long, long long>(F[g][1] - F[g][0], 1));
    else
      fv = G[first][i].second;
  }
  sort(V.begin(), V.end());
  F[first][1] = getpre(Sm[first], V, Deg[first] - T - 1) + fv + tot,
  F[first][0] = getpre(Sm[first], V, Deg[first] - T) + tot;
}
signed main() {
  scanf("%lld", &n);
  vector<long long> S(0);
  for (long long i = 1, a, b, c; i < n; i++)
    scanf("%lld%lld%lld", &L[i], &R[i], &V[i]),
        Go[++Cnt] = b = R[i], Next[Cnt] = Head[a = L[i]], Head[a = L[i]] = Cnt,
        Val[Cnt] = c = V[i], Deg[b = R[i]]++, Go[++Cnt] = a,
        Next[Cnt] = Head[b], Head[b] = Cnt, Val[Cnt] = c, Deg[a]++,
        G[a].push_back(pair<long long, long long>(b, c)),
        G[b].push_back(pair<long long, long long>(a, c)),
        Sm[a].push_back(pair<long long, long long>(c, 0)),
        Sm[b].push_back(pair<long long, long long>(c, 0));
  for (long long i = 1; i <= n; i++) S.push_back(i);
  for (long long i = 1; i <= n; i++)
    if (Sm[i].size()) {
      sort(G[i].begin(), G[i].end(), cmpP), sort(Sm[i].begin(), Sm[i].end()),
          Sm[i][0].second = Sm[i][0].first;
      for (long long j = 1; j < Sm[i].size(); j++)
        Sm[i][j].second = Sm[i][j - 1].second + Sm[i][j].first;
    }
  sort(S.begin(), S.end(), cmp);
  for (T = n - 1; T >= 0; T--) {
    while (St != S.size() && Deg[S[St]] > T) St++;
    long long ans = 0;
    for (long long i = 0; i < St; i++)
      if (vis[S[i]] != T + 1) DFS(S[i], -1), ans += F[S[i]][0];
    Ans[T] = ans;
  }
  for (long long i = 0; i < n; i++) printf("%lld ", Ans[i]);
}
