#include <bits/stdc++.h>
const int MAXN = 3e5 + 5;
int n;
std::vector<std::pair<int, int> > G[MAXN];
int deg[MAXN];
int now;
inline bool cmp(std::pair<int, int> x, std::pair<int, int> y) {
  return deg[x.first] > deg[y.first];
}
std::multiset<long long> big[MAXN], small[MAXN];
long long sm[MAXN];
int lim[MAXN];
inline void update(int o) {
  while (!big[o].empty() && small[o].size() < lim[o]) {
    small[o].insert(*big[o].begin());
    sm[o] += *big[o].begin();
    big[o].erase(big[o].begin());
  }
  while (small[o].size() > lim[o]) {
    sm[o] -= *small[o].rbegin();
    big[o].insert(*small[o].rbegin());
    small[o].erase((--small[o].end()));
  }
}
inline void insert(int o, long long x) {
  if (big[o].empty()) return (void)(small[o].insert(x), sm[o] += x);
  if (small[o].empty()) return (void)big[o].insert(x);
  if (x <= *small[o].rbegin()) return (void)(small[o].insert(x), sm[o] += x);
  return (void)big[o].insert(x);
}
inline void erase(int o, long long x) {
  auto p = big[o].find(x);
  if (p != big[o].end()) return (void)big[o].erase(p);
  return (void)(small[o].erase(small[o].find(x)), sm[o] -= x);
}
inline void gao(int v) {
  for (auto x : G[v]) {
    if (deg[x.first] <= now) break;
    insert(x.first, x.second);
  }
}
bool vis[MAXN];
long long f[MAXN][2];
inline void dfs(int v, int fa = 0) {
  f[v][0] = f[v][1] = 0;
  std::vector<long long> del;
  vis[v] = 1;
  lim[v] = deg[v] - now;
  for (auto x : G[v]) {
    if (x.first == fa) continue;
    if (deg[x.first] <= now) break;
    dfs(x.first, v);
    f[v][0] += f[x.first][0];
    f[v][1] += f[x.first][0];
    long long gx = -f[x.first][0] + x.second + f[x.first][1];
    if (gx <= 0)
      --lim[v], f[v][0] += gx, f[v][1] += gx;
    else
      insert(v, gx), del.push_back(gx);
  }
  lim[v] = std::max(lim[v], 0);
  update(v);
  f[v][0] += sm[v];
  --lim[v];
  lim[v] = std::max(lim[v], 0);
  update(v);
  f[v][1] += sm[v];
  for (auto x : del) erase(v, x);
  del.clear();
}
std::pair<int, int> node[MAXN];
int main() {
  scanf("%d", &n);
  long long sm = 0;
  for (int i = 2; i <= n; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    G[u].push_back(std::make_pair(v, w));
    G[v].push_back(std::make_pair(u, w));
    sm += w;
    ++deg[u];
    ++deg[v];
  }
  for (int i = 1; i <= n; ++i)
    std::sort(G[i].begin(), G[i].end(), cmp),
        node[i] = std::make_pair(deg[i], i);
  std::sort(node + 1, node + n + 1);
  int ps = 1;
  printf("%lld", sm);
  for (now = 1; now <= n - 1; ++now) {
    while (ps <= n && node[ps].first <= now) gao(node[ps].second), ++ps;
    long long ans = 0;
    for (int i = ps; i <= n; ++i) vis[node[i].second] = 0;
    for (int i = ps; i <= n; ++i) {
      int x = node[i].second;
      if (vis[x]) continue;
      dfs(x);
      ans += f[x][0];
    }
    printf(" %lld", ans);
  }
  puts("");
  return 0;
}
