#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  int f = 1;
  x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  x *= f;
}
void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x <= 9) {
    putchar(x + '0');
    return;
  }
  write(x / 10);
  putchar(x % 10 + '0');
}
const int MAXN = 1e6 + 5;
int n;
int d[MAXN], vis[MAXN];
long long dp[MAXN][2], _sum[MAXN];
vector<int> De[MAXN];
multiset<long long> Q[MAXN];
vector<pair<int, int> > G[MAXN];
void ins(int x, long long w) {
  Q[x].insert(w);
  _sum[x] += w;
}
void del(int x, long long w) {
  Q[x].erase(Q[x].find(w));
  _sum[x] -= w;
}
void dfs(int x, int fa, int goal) {
  vector<long long> ti, td;
  int si = d[x] - goal;
  si = max(si, 0);
  while (Q[x].size() > si) del(x, *Q[x].rbegin());
  long long res = 0;
  for (int i = 0; i < G[x].size(); ++i) {
    int v = G[x][i].first, w = G[x][i].second;
    if (d[v] <= goal) break;
    if (vis[v] == goal) continue;
    vis[v] = goal;
    dfs(v, x, goal);
    if (dp[v][0] < dp[v][1] + w) {
      res += dp[v][0];
      ins(x, dp[v][1] - dp[v][0] + w);
      ti.push_back(dp[v][1] - dp[v][0] + w);
    } else
      res += dp[v][1] + w, si--;
  }
  si = max(si, 0);
  while (Q[x].size() > si) {
    long long w = *Q[x].rbegin();
    td.push_back(w);
    del(x, w);
  }
  dp[x][0] = res + _sum[x];
  si = max(si - 1, 0);
  while (Q[x].size() > si) {
    long long w = *Q[x].rbegin();
    td.push_back(w);
    del(x, w);
  }
  dp[x][1] = res + _sum[x];
  for (int i = 0; i < td.size(); ++i) ins(x, td[i]);
  for (int i = 0; i < ti.size(); ++i) del(x, ti[i]);
}
bool cmp(pair<int, int> x, pair<int, int> y) { return d[x.first] > d[y.first]; }
pair<int, int> nd[MAXN];
signed main() {
  read(n);
  long long ans0 = 0;
  for (int i = 1; i < n; ++i) {
    int u, v, w;
    read(u);
    read(v);
    read(w);
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w));
    d[u]++;
    d[v]++;
    ans0 += w;
  }
  for (int i = 1; i <= n; ++i) {
    sort(G[i].begin(), G[i].end(), cmp);
    nd[i] = make_pair(d[i], i);
  }
  sort(nd + 1, nd + 1 + n);
  printf("%lld ", ans0);
  int cur = 1;
  for (int q = 1; q < n; ++q) {
    while (cur <= n && nd[cur].first == q) {
      int x = nd[cur].second;
      for (int i = 0; i < G[x].size(); ++i) {
        int v = G[x][i].first, w = G[x][i].second;
        if (d[v] <= q) break;
        ins(v, w);
      }
      cur++;
    }
    long long ans = 0;
    for (int i = cur; i <= n; ++i) {
      int v = nd[i].second;
      if (vis[v] != q) {
        vis[v] = q;
        dfs(v, 0, q);
        ans += dp[v][0];
      }
    }
    write(ans);
    putchar(' ');
    if (ans == 0) {
      for (int j = q + 1; j < n; ++j) putchar('0'), putchar(' ');
      break;
    }
  }
  return 0;
}
