#include <bits/stdc++.h>
using namespace std;
const int maxn = 25e4 + 10;
const long long inf = 1e16;
struct Set {
  set<pair<long long, int> > st, st2;
  vector<pair<bool, pair<long long, int> > > rec;
  long long sum = 0;
  void record() { rec.clear(); }
  void restart() {
    for (int i = int((rec).size()) - 1; i >= 0; i--) {
      if (rec[i].first)
        st.erase(rec[i].second), sum -= rec[i].second.first;
      else
        st.insert(rec[i].second), sum += rec[i].second.first;
    }
  }
  void add(pair<long long, int> x) {
    if (x.first <= 0) return;
    rec.push_back({1, x});
    st.insert(x);
    sum += x.first;
  }
  void era(pair<long long, int> x) {
    if (st.count(x) == 0) {
      st2.erase(x);
      return;
    }
    rec.push_back({0, x});
    st.erase(x);
    sum -= x.first;
  }
  void balance(int n) {
    while (int((st).size()) > n) {
      era(*st.begin());
    }
  }
  void _balance(int n) {
    while (int((st).size()) > n) {
      st2.insert(*st.begin());
      sum -= st.begin()->first;
      st.erase(st.begin());
    }
    while (int((st).size()) < n && int((st2).size())) {
      st.insert(*st2.rbegin());
      sum += st2.rbegin()->first;
      st2.erase(*st2.rbegin());
    }
  }
};
Set st[maxn];
long long dp[2][maxn], total[maxn], ans[maxn];
bool in[maxn];
int ids[maxn], mark[maxn], mrk;
vector<pair<int, int> > g[maxn], v[maxn];
void dfs(int u, int k) {
  mark[u] = mrk;
  st[u]._balance(k);
  st[u].record();
  dp[0][u] = total[u];
  for (pair<int, int> p : v[u]) {
    if (mark[p.first] != mrk) {
      dfs(p.first, k);
      st[u].add({dp[0][p.first] + p.second - dp[1][p.first], -p.first - 10});
      dp[0][u] += dp[0][p.first];
    } else {
      dp[0][u] -= p.second;
    }
  }
  st[u].balance(k);
  dp[1][u] = dp[0][u];
  dp[0][u] -= st[u].sum;
  if (k > 0)
    st[u].balance(k - 1), dp[1][u] -= st[u].sum;
  else
    dp[1][u] = inf;
  st[u].restart();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    g[a].push_back({b, c});
    g[b].push_back({a, c});
    st[a].add({c, b});
    st[b].add({c, a});
    total[a] += c;
    total[b] += c;
  }
  for (int i = 0; i < n; i++) {
    ids[i] = i;
  }
  sort(ids, ids + n,
       [](int a, int b) { return int((g[a]).size()) > int((g[b]).size()); });
  int pt = 0;
  for (int i = n - 1; i >= 0; i--) {
    while (pt<n&& int((g[ids[pt]]).size())> i) {
      int u = ids[pt++];
      for (pair<int, int> p : g[u]) {
        if (in[p.first]) {
          v[p.first].push_back({u, p.second});
          v[u].push_back(p);
          st[u].era({p.second, p.first});
          st[p.first].era({p.second, u});
        }
      }
      in[u] = 1;
    }
    ++mrk;
    for (int j = 0; j < pt; j++) {
      if (mark[ids[j]] != mrk) dfs(ids[j], i), ans[i] += dp[0][ids[j]];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  return cout << endl, 0;
}
