#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,tune=native")
template <typename T>
void print(T&& x) {
  cout << x << "\n";
}
template <typename T, typename... S>
void print(T&& x, S&&... y) {
  cout << x << ' ';
  print(y...);
}
const long long Mod = 1000000007, Mod2 = 998244353;
const long long MOD = Mod;
const long long maxn = 250005;
long long n, deg[maxn];
long long dp[maxn][2];
vector<pair<long long, long long> > adj[maxn];
vector<long long> res, vec[maxn], nodes, ind[maxn], val[maxn];
map<long long, long long> rev[maxn];
bool vis[maxn];
struct BIT {
  vector<long long> val;
  void modify(long long x, long long y) {
    for (long long i = ++x; i < ((long long)val.size()); i += i & -i)
      val[i] += y;
  }
  long long query(long long x, long long y) {
    long long ret = 0;
    for (long long i = ++y; i > 0; i -= i & -i) ret += val[i];
    for (long long i = x; i > 0; i -= i & -i) ret -= val[i];
    return ret;
  }
};
BIT bitcnt[maxn], bit[maxn];
void dfs(long long u, long long par, long long k) {
  vis[u] = 1;
  for (auto [v, w] : adj[u]) {
    if (deg[v] < k) break;
    if (v != par) dfs(v, u, k);
  }
  vector<long long> vec;
  dp[u][0] = dp[u][1] = 0;
  for (auto [v, w] : adj[u]) {
    if (deg[v] < k) break;
    if (v != par)
      vec.push_back((dp[v][0] + w) - dp[v][1]), dp[u][0] += dp[v][1],
          dp[u][1] += dp[v][1];
  }
  sort(vec.begin(), vec.end());
  long long need = deg[u] - 1 - k;
  if (par == -1) need++;
  if (k == 2 && u == 0) 826, 826;
  reverse(vec.begin(), vec.end());
  while (((long long)vec.size()) && vec.back() < 0)
    dp[u][0] += vec.back(), vec.pop_back(), need--;
  reverse(vec.begin(), vec.end());
  dp[u][1] = dp[u][0];
  long long minn, tot;
  if (k == 2 && u == 0) {
    for (long long i = (0); i < ((long long)(deg[u])); i++) 826;
  }
  for (long long _ = (0); _ < ((long long)(2)); _++) {
    minn = 4000000000000000000, tot = 0;
    if (need > 0) {
      for (long long j = (0); j < ((long long)(((long long)vec.size()) + 1));
           j++) {
        long long cur = 0, curcnt = 0;
        for (long long i = (17); i >= ((long long)(0)); i--) {
          if (cur + (1ll << (i)) >= deg[u]) continue;
          if (curcnt + bitcnt[u].val[cur + (1ll << (i))] + j <= need) {
            cur += (1ll << (i));
            curcnt += bitcnt[u].val[cur];
          }
        }
        if (k == 2 && u == 0) 826;
        if (curcnt + j == need)
          minn = min(minn, tot + bit[u].query(0, cur - 1)), 826;
        if (j < ((long long)vec.size())) tot += vec[j];
      }
      dp[u][_] += minn;
    }
    need++;
  }
  826;
}
void orzck() {
  cin >> n;
  for (long long i = (0); i < ((long long)(n - 1)); i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    adj[u].push_back({v, w}), adj[v].push_back({u, w});
    deg[u]++, deg[v]++;
  }
  for (long long i = (0); i < ((long long)(n)); i++)
    sort(adj[i].begin(), adj[i].end(),
         [](pair<long long, long long> x, pair<long long, long long> y) {
           return deg[x.first] > deg[y.first];
         });
  for (long long i = (0); i < ((long long)(n)); i++) vec[deg[i]].push_back(i);
  for (long long i = (0); i < ((long long)(n)); i++) nodes.push_back(i);
  sort(nodes.begin(), nodes.end(),
       [](long long x, long long y) { return deg[x] > deg[y]; });
  for (long long i = (0); i < ((long long)(n)); i++) {
    bitcnt[i].val.resize(((long long)adj[i].size()) + 1);
    bit[i].val.resize(((long long)adj[i].size()) + 1);
    ind[i].resize(((long long)adj[i].size()));
    for (long long j = (0); j < ((long long)(((long long)ind[i].size()))); j++)
      ind[i][j] = j;
    sort(ind[i].begin(), ind[i].end(), [i](long long x, long long y) {
      return adj[i][x].second < adj[i][y].second;
    });
    for (long long j = (0); j < ((long long)(((long long)ind[i].size()))); j++)
      rev[i][adj[i][ind[i][j]].first] = j;
    val[i].resize(((long long)adj[i].size()));
  }
  res.resize(n);
  for (long long i = (0); i < ((long long)(n)); i++) {
    for (auto j : nodes) vis[j] = 0;
    for (auto j : nodes)
      if (!vis[j]) dfs(j, -1, i), res[i] += dp[j][0], 826;
    while (((long long)nodes.size()) && deg[nodes.back()] <= i)
      nodes.pop_back();
    for (auto j : vec[i])
      for (auto& [v, w] : adj[j])
        bitcnt[v].modify(rev[v][j], 1), bit[v].modify(rev[v][j], w);
  }
  for (auto i : res) cout << (i) << ' ';
  cout << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cout << fixed << setprecision(15);
  long long t;
  t = 1;
  while (t--) orzck();
  return 0;
}
