#include <bits/stdc++.h>
using namespace std;
const int N = 250005;
const int MX = 1000005;
const int M = 10500005;
struct edge {
  int to, next, v;
} e[N * 2];
int head[N], deg[N], q[N];
int n, Q, T, tot, vis[N], Rt[N];
int X[N], Y[N], V[N], rt[N], pos[N];
vector<int> vece[N], vecp[N];
void add(int x, int y, int v) {
  e[++tot] = (edge){y, head[x], v};
  head[x] = tot;
  e[++tot] = (edge){x, head[y], v};
  head[y] = tot;
}
int nd, flag, ls[M], rs[M], sz[M];
long long S[M], ans[N];
void insert(int &nk, int k, int l, int r, int x, int y) {
  if (flag) {
    nk = ++nd;
    ls[nk] = ls[k];
    rs[nk] = rs[k];
  } else
    nk = (k ? k : ++nd);
  S[nk] = S[k] + x * y;
  sz[nk] = sz[k] + y;
  if (l == r) return;
  int mid = (l + r) / 2;
  if (x <= mid)
    insert(ls[nk], ls[k], l, mid, x, y);
  else
    insert(rs[nk], rs[k], mid + 1, r, x, y);
  if (!sz[ls[nk]]) ls[nk] = 0;
  if (!sz[rs[nk]]) rs[nk] = 0;
}
long long ask(int k, int l, int r, int rk) {
  if (!k) return 0;
  if (sz[k] == rk) return S[k];
  if (l == r) return 1ll * rk * l;
  int mid = (l + r) / 2;
  if (sz[ls[k]] >= rk) return ask(ls[k], l, mid, rk);
  return ask(rs[k], mid + 1, r, rk - sz[ls[k]]) + S[ls[k]];
}
pair<long long, long long> wzp[N];
pair<long long, long long> dfs(int x, int fa, int d) {
  vis[x] = T;
  pair<long long, long long> res(0, 0);
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].to != fa) {
      pair<long long, long long> tmp = dfs(e[i].to, x, d);
      assert(tmp.second <= tmp.first);
      tmp.second = tmp.second + e[i].v;
      tmp.first = min(tmp.first, tmp.second);
      res.first += tmp.first;
      res.second += tmp.first;
      insert(Rt[x], Rt[x], 0, MX, tmp.second - tmp.first, 1);
    }
  int del = deg[x] - d;
  res.first += ask(Rt[x], 0, MX, del);
  res.second += ask(Rt[x], 0, MX, del - 1);
  wzp[x] = res;
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    scanf("%d%d%d", &X[i], &Y[i], &V[i]);
    ++deg[X[i]];
    ++deg[Y[i]];
  }
  for (int i = (int)(1); i <= (int)(n - 1); i++)
    vece[min(deg[X[i]], deg[Y[i]]) - 1].push_back(i);
  for (int i = (int)(0); i <= (int)(n - 1); i++) {
    int sz = vece[i].size();
    for (int j = (int)(0); j <= (int)(vece[i].size() - 1); j++) {
      int id = vece[i][j];
      insert(rt[X[id]], rt[X[id]], 0, MX, V[id], 1);
      insert(rt[Y[id]], rt[Y[id]], 0, MX, V[id], 1);
    }
    pos[i] = nd;
  }
  for (int i = (int)(1); i <= (int)(n); i++) vecp[deg[i] - 1].push_back(i);
  for (int i = (int)(n - 1); i >= (int)(0); i--) {
    for (int j = (int)(0); j <= (int)(vece[i].size() - 1); j++) {
      int id = vece[i][j];
      add(X[id], Y[id], V[id]);
      insert(rt[X[id]], rt[X[id]], 0, MX, V[id], -1);
      insert(rt[Y[id]], rt[Y[id]], 0, MX, V[id], -1);
      if (!sz[rt[X[id]]]) rt[X[id]] = 0;
      if (!sz[rt[Y[id]]]) rt[Y[id]] = 0;
    }
    for (; nd > (i ? pos[i - 1] : 0); --nd)
      sz[nd] = S[nd] = ls[nd] = rs[nd] = 0;
    for (int j = (int)(0); j <= (int)(vecp[i].size() - 1); j++)
      q[++*q] = vecp[i][j];
    for (int j = (int)(1); j <= (int)(*q); j++) Rt[q[j]] = rt[q[j]];
    int tmp = nd;
    ++T;
    flag = 1;
    sort(q + 1, q + *q + 1);
    for (int j = (int)(1); j <= (int)(*q); j++)
      if (vis[q[j]] != T) ans[i] += dfs(q[j], 0, i).first;
    flag = 0;
  }
  for (int i = (int)(0); i <= (int)(n - 1); i++) printf("%lld ", ans[i]);
}
