#include <bits/stdc++.h>
using namespace std;
string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  DBG(t...);
}
const int INF = 1e9 + 7, N = 250007;
struct Sum_set {
  multiset<int> s;
  long long sum;
  Sum_set() { sum = 0LL; }
  void insert(int x) {
    sum += x;
    s.insert(x);
  }
  void erase(int x) {
    sum -= x;
    s.erase(s.find(x));
  }
  int size() { return s.size(); }
  int top() {
    assert(s.size());
    return *s.rbegin();
  }
  void pop() {
    assert(s.size());
    sum -= *s.rbegin();
    s.erase(s.find(*s.rbegin()));
  }
} ds[N];
set<pair<int, int> > G[N];
vector<int> with_deg[N];
int vis[N], deg[N];
long long dp[N][2];
signed main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  int n;
  cin >> n;
  long long tot_w = 0;
  for (int i = 0; i < n - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    tot_w += w;
    G[u].emplace(v, w);
    G[v].emplace(u, w);
  }
  for (int i = 1; i <= n; i++) with_deg[deg[i] = int(G[i].size())].push_back(i);
  set<int> alive;
  for (int i = 1; i <= n; i++) alive.insert(i);
  auto solve = [&](int k) {
    function<void(int, int)> dfs = [&](int u, int p) {
      vis[u] = 1;
      long long dp_val = 0;
      int del = max(deg[u] - k, 0);
      while (ds[u].size() > del) ds[u].pop();
      vector<int> undo_ins, undo_del;
      for (pair<int, int> e : G[u])
        if (e.first != p) {
          int v, w;
          tie(v, w) = e;
          dfs(v, u);
          dp_val += dp[v][1];
          undo_ins.push_back(w - (dp[v][1] - dp[v][0]));
          ds[u].insert(w - (dp[v][1] - dp[v][0]));
          while (ds[u].size() > del) {
            if (ds[u].top() < 0) dp_val += ds[u].top();
            undo_del.push_back(ds[u].top()), ds[u].pop();
          }
        }
      dp_val += ds[u].sum;
      dp[u][0] = dp[u][1] = dp_val;
      if (ds[u].size() && ds[u].top() > 0) dp[u][0] = dp_val - ds[u].top();
      for (int x : undo_del) ds[u].insert(x);
      for (int x : undo_ins) ds[u].erase(x);
    };
    long long ans = 0;
    for (int i : alive)
      if (!vis[i]) {
        dfs(i, 0);
        ans += dp[i][1];
      }
    for (int i : alive) vis[i] = 0;
    return ans;
  };
  cout << tot_w << ' ';
  for (int i = 1; i < n; i++) {
    for (int u : with_deg[i]) {
      alive.erase(u);
      for (pair<int, int> e : G[u]) {
        int v, w;
        tie(v, w) = e;
        assert(alive.count(v));
        ds[v].insert(w);
        G[v].erase({u, w});
      }
    }
    cout << solve(i) << ' ';
  }
}
