#include <bits/stdc++.h>
using namespace std;
long long n, md, sum, ans, ds[250100], vis[250100], nxt[250100], dp[250100][2];
struct Pq {
  long long size, sum;
  priority_queue<long long> a, b;
  void push(long long u) { a.push(u), size++, sum += u; }
  void del(long long u) { b.push(u), size--, sum -= u; }
  void cle() {
    for (; !a.empty() && !b.empty() && a.top() == b.top(); a.pop(), b.pop())
      ;
  }
  void pop() { cle(), sum -= a.top(), a.pop(), size--; }
  bool empty() {
    cle();
    return a.empty();
  }
  long long top() {
    cle();
    return a.top();
  }
} pq[250100];
vector<pair<long long, long long> > to[250100];
vector<long long> have[250100], use, gg;
inline bool cmp(pair<long long, long long> u, pair<long long, long long> v) {
  return ds[u.first] > ds[v.first];
}
inline void del(long long u) {
  long long i, t, p, q;
  for (i = 0; i < to[u].size(); i++) {
    p = to[u][i].first, q = to[u][i].second;
    if (ds[p] <= md) break;
    pq[p].push(q);
  }
}
void dfs(long long now, long long last) {
  long long i, j, p, q, cnt = ds[now] - md, res = 0;
  vis[now] = md;
  for (; pq[now].size > ds[now] - md; pq[now].pop())
    ;
  for (i = 0; i < to[now].size(); i++) {
    p = to[now][i].first;
    if (ds[p] <= md) break;
    if (p == last) continue;
    dfs(p, now);
  }
  use.clear(), gg.clear();
  for (i = 0; i < to[now].size(); i++) {
    p = to[now][i].first, q = to[now][i].second;
    if (ds[p] <= md) break;
    if (p == last) continue;
    long long t = dp[p][1] + q - dp[p][0];
    if (t < 0) {
      cnt--;
      res += dp[p][0] + t;
      continue;
    }
    res += dp[p][0];
    pq[now].push(t);
    use.push_back(t);
  }
  for (; !pq[now].empty() && pq[now].size > cnt; pq[now].pop())
    gg.push_back(pq[now].top());
  dp[now][0] = res + pq[now].sum;
  for (; !pq[now].empty() && pq[now].size > cnt - 1; pq[now].pop())
    gg.push_back(pq[now].top());
  dp[now][1] = res + pq[now].sum;
  for (i = 0; i < gg.size(); i++) pq[now].push(gg[i]);
  for (i = 0; i < use.size(); i++) pq[now].del(use[i]);
}
int main() {
  long long i, j, t, p, q, o;
  cin >> n;
  for (i = 1; i < n; i++) {
    scanf("%lld%lld%lld", &p, &q, &o);
    to[p].push_back(make_pair(q, o));
    to[q].push_back(make_pair(p, o));
    ds[p]++, ds[q]++, sum += o;
  }
  for (i = 1; i <= n; i++) {
    have[ds[i]].push_back(i);
    sort(to[i].begin(), to[i].end(), cmp);
  }
  for (i = n; i >= 1; i--) {
    if (have[i + 1].size())
      nxt[i] = i + 1;
    else
      nxt[i] = nxt[i + 1];
  }
  cout << sum << " ";
  for (md = 1; md < n; md++) {
    ans = 0;
    for (i = 0; i < have[md].size(); i++) del(have[md][i]);
    for (i = md + 1; i; i = nxt[i]) {
      for (j = 0; j < have[i].size(); j++) {
        t = have[i][j];
        if (vis[t] == md) continue;
        dfs(t, -1);
        ans += dp[t][0];
      }
    }
    printf("%lld ", ans);
  }
}
