#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline void read(T &x) {
  char ch = getchar();
  int f = 1;
  x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
template <typename T, typename... Args>
inline void read(T &x, Args &...args) {
  read(x), read(args...);
}
int n, deg[250050];
set<int> se;
vector<int> ver[250050];
vector<pair<int, int> > adj[250050];
struct Set {
  priority_queue<long long> x, y;
  long long sum;
  void upd() {
    while (!y.empty() && x.top() == y.top()) x.pop(), y.pop();
  }
  long long top() {
    upd();
    return x.top();
  }
  void pop() { upd(), sum -= x.top(), x.pop(); }
  int size() { return x.size() - y.size(); }
  bool empty() { return x.size() == y.size(); }
  void insert(long long w) { x.push(w), sum += w; }
  void erase(long long w) { y.push(w), sum -= w; }
} h[250050];
bool cmp(pair<int, int> x, pair<int, int> y) {
  return deg[x.second] > deg[y.second];
}
void delet(int u) {
  se.erase(u);
  for (auto pa : adj[u]) h[pa.second].insert(pa.first);
}
vector<long long> should_add, should_ers;
long long dp[250050][2];
int curd, vis[250050];
void solve(int u, int fa) {
  int cnt = deg[u] - curd;
  long long res = 0;
  vis[u] = curd;
  while (h[u].size() > cnt) h[u].pop();
  for (auto pa : adj[u])
    if (pa.second != fa) {
      if (deg[pa.second] <= curd) break;
      solve(pa.second, u);
    }
  should_ers.clear(), should_add.clear();
  for (auto pa : adj[u])
    if (pa.second != fa) {
      if (deg[pa.second] <= curd) break;
      if (dp[pa.second][1] + pa.first <= dp[pa.second][0])
        --cnt, res += dp[pa.second][1] + pa.first;
      else
        res += dp[pa.second][0],
            h[u].insert(dp[pa.second][1] + pa.first - dp[pa.second][0]),
            should_ers.push_back(dp[pa.second][1] + pa.first -
                                 dp[pa.second][0]);
    }
  while (!h[u].empty() && h[u].size() > cnt)
    should_add.push_back(h[u].top()), h[u].pop();
  dp[u][0] = res + h[u].sum;
  while (!h[u].empty() && h[u].size() > cnt - 1)
    should_add.push_back(h[u].top()), h[u].pop();
  dp[u][1] = res + h[u].sum;
  for (auto x : should_add) h[u].insert(x);
  for (auto x : should_ers) h[u].erase(x);
}
int main() {
  read(n);
  int u, v, w;
  for (register int i = 1; i <= n - 1; ++i)
    read(u, v, w), adj[u].push_back(make_pair(w, v)),
        adj[v].push_back(make_pair(w, u)), ++deg[u], ++deg[v];
  for (register int i = 1; i <= n; ++i)
    sort(adj[i].begin(), adj[i].end(), cmp), se.insert(i),
        ver[deg[i]].push_back(i);
  long long ans = 0;
  memset(vis, -1, sizeof(vis));
  for (curd = 0; curd < n; curd++) {
    ans = 0;
    for (auto v : ver[curd]) delet(v);
    for (auto v : se)
      if (vis[v] != curd) solve(v, 0), ans += dp[v][0];
    cout << ans << ' ';
  }
  return 0;
}
