#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  bool t = false;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') t = true, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
  return t ? -x : x;
}
int n, dg[250250];
long long ans;
vector<int> D[250250], DD[250250];
struct Line {
  int v, w;
};
vector<Line> E[250250];
bool operator<(Line a, Line b) { return dg[a.v] < dg[b.v]; }
inline void Add(int u, int v, int w) {
  E[u].push_back((Line){v, w});
  ++dg[u];
}
long long f[250250][2], sum[250250];
int Limit, h[250250];
bool vis[250250];
multiset<long long, greater<long long> > S[250250];
void Del(int x, int l) {
  while (S[x].size() > l) sum[x] -= *S[x].begin(), S[x].erase(S[x].begin());
}
void Del(int x, int l, vector<long long> &p) {
  while (S[x].size() > l)
    sum[x] -= *S[x].begin(), p.push_back(*S[x].begin()),
        S[x].erase(S[x].begin());
}
void dfs(int u, int ff) {
  int m = dg[u] - Limit;
  long long tot = 0;
  vis[u] = true;
  vector<long long> val1, val2;
  Del(u, max(0, m));
  while (h[u] < E[u].size() && dg[E[u][h[u]].v] <= Limit) ++h[u];
  for (int i = h[u]; i < E[u].size(); ++i) {
    int v = E[u][i].v, w = E[u][i].w;
    if (vis[v] || ff == v) continue;
    dfs(v, u);
    if (f[v][1] + w <= f[v][0])
      --m, tot += f[v][1] + w;
    else {
      tot += f[v][0];
      long long ss = f[v][1] - f[v][0] + w;
      S[u].insert(ss);
      sum[u] += ss;
      val2.push_back(ss);
    }
  }
  Del(u, max(0, m), val1);
  f[u][0] = tot + sum[u];
  --m;
  Del(u, max(0, m), val1);
  f[u][1] = tot + sum[u];
  for (int i : val1) S[u].insert(i), sum[u] += i;
  for (int i : val2) S[u].erase(S[u].find(i)), sum[u] -= i;
}
int main() {
  n = read();
  for (int i = 1; i < n; ++i) {
    int u = read(), v = read(), w = read();
    ans += w;
    Add(u, v, w);
    Add(v, u, w);
  }
  for (int i = 1; i <= n; ++i) sort(E[i].begin(), E[i].end());
  for (int i = 1; i <= n; ++i) DD[dg[i]].push_back(i);
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < dg[i]; ++j) D[j].push_back(i);
  printf("%lld ", ans);
  for (int i = 1; i < n; ++i) {
    Limit = i;
    ans = 0;
    for (int u : DD[i])
      for (auto p : E[u]) {
        int v = p.v, w = p.w;
        if (vis[v]) continue;
        S[v].insert(w);
        sum[v] += w;
      }
    for (int u : DD[i]) vis[u] = true;
    for (int v : D[i]) {
      if (vis[v]) continue;
      dfs(v, 0);
      ans += f[v][0];
    }
    for (int v : D[i]) vis[v] = false;
    printf("%lld ", ans);
  }
}
