#include <bits/stdc++.h>
using namespace std;
struct st {
  long long v, e;
  st() {}
  st(long long A, long long B) { v = A, e = B; }
};
vector<long long> live[300005], du[300005];
vector<st> G[300005];
long long in[300005], vis[300005];
long long dp[300005][2], siz[300005], sum[300005], pos[300005];
multiset<long long> S[300005];
void insert(long long x, long long y) {
  S[x].insert(y);
  siz[x]++;
  sum[x] += y;
  return;
}
void remove(long long x, long long y) {
  S[x].erase(S[x].find(y));
  siz[x]--;
  sum[x] -= y;
}
void dfs(long long x, long long tot) {
  vis[x] = 1;
  long long p = in[x] - tot;
  while (siz[x] > max(p, 0ll)) remove(x, *S[x].rbegin());
  while (pos[x] < in[x] && in[G[x][pos[x]].v] <= tot) pos[x]++;
  long long res = 0, add = 0;
  vector<long long> AP, BP;
  for (long long i = pos[x]; i < in[x]; i++) {
    long long y = G[x][i].v, e = G[x][i].e;
    if (vis[y]) continue;
    dfs(y, tot);
    if ((add = dp[y][1] - dp[y][0] + e) <= 0) {
      p--;
      res += dp[y][1] + e;
    } else {
      AP.push_back(add);
      insert(x, add);
      res += dp[y][0];
    }
  }
  while (siz[x] > max(p, 0ll))
    BP.push_back(add = *S[x].rbegin()), remove(x, add);
  dp[x][0] = res + sum[x];
  while (siz[x] > max(p - 1, 0ll))
    BP.push_back(add = *S[x].rbegin()), remove(x, add);
  dp[x][1] = res + sum[x];
  while (BP.size()) insert(x, BP.back()), BP.pop_back();
  while (AP.size()) remove(x, AP.back()), AP.pop_back();
}
bool cmp(st x, st y) { return in[x.v] < in[y.v]; }
signed main() {
  long long n, ans = 0;
  scanf("%lld", &n);
  for (long long i = 1; i < n; i++) {
    long long u, v, e;
    scanf("%lld %lld %lld", &u, &v, &e);
    G[u].push_back(st(v, e));
    G[v].push_back(st(u, e));
    in[u]++, in[v]++;
    ans += e;
  }
  for (long long i = 1; i <= n; i++) sort(G[i].begin(), G[i].end(), cmp);
  for (long long i = 1; i <= n; i++) du[in[i]].push_back(i);
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j < in[i]; j++) live[j].push_back(i);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < du[i].size(); j++) {
      long long x = du[i][j];
      vis[x] = 1;
      for (long long k = 0; k < G[x].size(); k++) {
        long long y = G[x][k].v;
        if (vis[y] == 0) {
          insert(y, G[x][k].e);
        }
      }
    }
    for (long long j = 0; j < live[i].size(); j++) {
      long long x = live[i][j];
      if (vis[x] == 0) {
        dfs(x, i);
        ans += dp[x][0];
      }
    }
    for (long long j = 0; j < live[i].size(); j++) vis[live[i][j]] = 0;
    printf("%lld ", ans);
    ans = 0;
  }
  return 0;
}
