#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void cmin(T &a, T b) {
  ((a > b) && (a = b));
}
template <class T>
inline void cmax(T &a, T b) {
  ((a < b) && (a = b));
}
char IO;
template <class T = int>
T rd() {
  T s = 0;
  int f = 0;
  while (!isdigit(IO = getchar())) f |= IO == '-';
  do s = (s << 1) + (s << 3) + (IO ^ '0');
  while (isdigit(IO = getchar()));
  return f ? -s : s;
}
const int N = 2.5e5 + 10, U = 1e6, M = N * 40;
int n, m;
int A[N], C, D[N];
vector<pair<int, int> > E[N], G[N];
int I[N], V[N];
int rt[N], ls[M], rs[M], c[M], cnt;
long long s[M];
void Upd(int &p, int l, int r, int x, int y) {
  if (!p) p = ++cnt;
  s[p] += x * y, c[p] += y;
  if (l == r) return;
  int mid = (l + r) >> 1;
  x <= mid ? Upd(ls[p], l, mid, x, y) : Upd(rs[p], mid + 1, r, x, y);
}
long long Que(int p, int l, int r, int k) {
  if (c[p] < k) return 1e18;
  if (!k || l == r) return l * k;
  int mid = (l + r) >> 1;
  if (c[ls[p]] >= k) return Que(ls[p], l, mid, k);
  return s[ls[p]] + Que(rs[p], mid + 1, r, k - c[ls[p]]);
}
long long dp[N][2];
int vis[N];
void dfs(int u) {
  vis[u] = 1;
  dp[u][0] = dp[u][1] = 0;
  vector<long long> val;
  int c = 0;
  long long s = 0;
  for (pair<int, int> t : G[u]) {
    int v = t.first, w = t.second;
    if (vis[v]) continue;
    dfs(v);
    dp[v][1] += w, s += dp[v][0];
    if (dp[v][1] <= dp[v][0])
      c++, s += dp[v][1] - dp[v][0];
    else
      val.push_back(dp[v][1] - dp[v][0]);
  }
  sort(val.begin(), val.end());
  auto F = [&](int k) {
    long long ans = Que(rt[u], 1, U, k), s = 0;
    for (long long i : val) {
      if (--k < 0) break;
      cmin(ans, (s += i) + Que(rt[u], 1, U, k));
    }
    return ans;
  };
  dp[u][0] = s + F(max(0, D[u] - c - m));
  dp[u][1] = s + F(max(0, D[u] - c - 1 - m));
}
long long ans[N];
int main() {
  n = rd();
  for (int i = 2, iend = n; i <= iend; ++i) {
    int u = rd(), v = rd(), w = rd();
    ans[0] += w;
    E[u].push_back(make_pair(v, w)), E[v].push_back(make_pair(u, w));
    Upd(rt[u], 1, U, w, 1), Upd(rt[v], 1, U, w, 1);
    D[u]++, D[v]++;
  }
  for (int i = 1, iend = n; i <= iend; ++i) I[i] = i;
  sort(I + 1, I + n + 1, [&](int x, int y) { return D[x] > D[y]; });
  int p = 1;
  for (m = n - 1; m; m--) {
    while (p && D[I[p]] > m) {
      int u = I[p++];
      V[A[++C] = u] = 1;
      for (pair<int, int> v : E[u])
        if (V[v.first]) {
          Upd(rt[u], 1, U, v.second, -1), Upd(rt[v.first], 1, U, v.second, -1);
          G[u].push_back(v), G[v.first].push_back(make_pair(u, v.second));
        }
    }
    for (int i = 1, iend = C; i <= iend; ++i) vis[A[i]] = 0;
    for (int i = 1, iend = C; i <= iend; ++i)
      if (!vis[A[i]]) dfs(A[i]), ans[m] += dp[A[i]][0];
  }
  for (int i = 0, iend = n - 1; i <= iend; ++i) printf("%lld ", ans[i]);
}
