#include <bits/stdc++.h>
using namespace std;
char buf[1 << 21], *p1 = buf, *p2 = buf;
template <class T>
void read(T &x) {
  x = 0;
  int c = getchar();
  int flag = 0;
  while (c < '0' || c > '9') flag |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
template <class T>
T _max(T a, T b) {
  return b < a ? a : b;
}
template <class T>
T _min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
bool checkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
bool checkmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
const int N = 300005;
int n, k, deg[N];
int cur[N];
vector<pair<int, int> > G[N];
vector<int> D[N], w[N];
multiset<long long> S[N];
int vis[N];
long long dp[N][2], sum[N];
long long ans[N];
void add_edge(int x, int y, int z) {
  G[x].push_back(make_pair(y, z));
  ++deg[y];
}
void init() {
  read(n);
  for (int i = 1, u, v, w; i < n; ++i) {
    read(u);
    read(v);
    read(w);
    add_edge(u, v, w);
    add_edge(v, u, w);
    ans[0] += w;
  }
  for (int i = 1; i <= n; ++i) {
    sort(G[i].begin(), G[i].end(), [&](pair<int, int> c1, pair<int, int> c2) {
      return deg[c1.first] < deg[c2.first];
    });
  }
  for (int i = 1; i <= n; ++i) {
    D[deg[i]].push_back(i);
    for (int j = 1; j < deg[i]; ++j) {
      w[j].push_back(i);
    }
  }
}
void ins(int x, long long z) {
  S[x].insert(z);
  sum[x] += z;
}
void del(int x, long long z) {
  S[x].erase(S[x].find(z));
  sum[x] -= z;
}
void dfs(int x) {
  vis[x] = 1;
  while (cur[x] < deg[x] && deg[G[x][cur[x]].first] <= k) ++cur[x];
  int lim = deg[x] - k, z0 = _max(lim, 0), z1 = _max(lim - 1, 0);
  while ((int)S[x].size() > z0) del(x, *S[x].rbegin());
  long long p = 0;
  vector<long long> ains, adel;
  for (int i = cur[x]; i < deg[x]; ++i) {
    int to = G[x][i].first, val = G[x][i].second;
    if (vis[to]) continue;
    dfs(to);
    if (dp[to][1] + val <= dp[to][0]) {
      p += dp[to][1] + val;
      --lim;
      continue;
    }
    p += dp[to][0];
    long long t = dp[to][1] + val - dp[to][0];
    ins(x, t);
    ains.push_back(t);
  }
  z0 = _max(lim, 0), z1 = _max(lim - 1, 0);
  while ((int)S[x].size() > z0) {
    long long t = *S[x].rbegin();
    adel.push_back(t);
    del(x, t);
  }
  dp[x][0] = p + sum[x];
  while ((int)S[x].size() > z1) {
    long long t = *S[x].rbegin();
    adel.push_back(t);
    del(x, t);
  }
  dp[x][1] = p + sum[x];
  for (auto p : adel) ins(x, p);
  for (auto p : ains) del(x, p);
}
void solve() {
  for (k = 1; k < n; ++k) {
    for (auto x : D[k]) {
      vis[x] = 1;
      for (auto p : G[x]) {
        if (!vis[p.first]) ins(p.first, p.second);
      }
    }
    for (auto x : w[k]) {
      if (!vis[x]) {
        dfs(x);
        ans[k] += dp[x][0];
      }
    }
    for (auto x : w[k]) vis[x] = 0;
  }
  for (int i = 0; i < n; ++i) printf("%lld ", ans[i]);
  printf("\n");
}
int main() {
  init();
  solve();
  return 0;
}
