#include <bits/stdc++.h>
using namespace std;
const long long N = 250005;
long long n;
long long du[N], nxt[N], vis[N];
long long sum[N];
vector<pair<long long, long long> > e[N];
vector<long long> d[N];
inline long long read() {
  char ch = getchar();
  long long s = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = (s << 3) + (s << 1) + ch - '0';
    ch = getchar();
  }
  return s * f;
}
bool cmp(pair<long long, long long> x, pair<long long, long long> y) {
  return du[x.first] < du[y.first];
}
struct node {
  priority_queue<long long> A, B;
  void push(long long x) { A.push(x); }
  void del(long long x) { B.push(x); }
  long long top() {
    while (!B.empty() && A.top() == B.top()) A.pop(), B.pop();
    return A.top();
  }
  void pop() {
    top();
    A.pop();
  }
  long long size() { return A.size() - B.size(); }
} h[N];
void upd(long long x, long long num) {
  while (h[x].size() > num) {
    sum[x] = sum[x] - h[x].top();
    h[x].pop();
  }
}
void upd1(long long x, long long num, vector<long long> &add) {
  while (h[x].size() > num) {
    sum[x] = sum[x] - h[x].top();
    add.push_back(h[x].top());
    h[x].pop();
  }
}
void dele(long long x) {
  vis[x] = 1;
  for (long long i = 0; i < e[x].size(); i++) {
    long long y = e[x][i].first, c = e[x][i].second;
    if (vis[y]) continue;
    h[y].push(c);
    sum[y] = sum[y] + c;
  }
}
long long D;
long long f[N][2], st[N];
void dfs(long long x) {
  vis[x] = 1;
  long long num = du[x] - D;
  upd(x, num);
  vector<long long> add, del;
  add.clear();
  del.clear();
  long long siz = e[x].size(), tot = 0;
  while (st[x] < siz && du[e[x][st[x]].first] <= D) st[x]++;
  for (long long i = st[x]; i < siz; i++) {
    long long y = e[x][i].first, c = e[x][i].second;
    ;
    if (vis[y]) continue;
    dfs(y);
    if (f[y][1] + c <= f[y][0]) {
      num--;
      tot = tot + f[y][1] + c;
    } else {
      tot = tot + f[y][0];
      long long o = f[y][1] + c - f[y][0];
      del.push_back(o);
      h[x].push(o);
      sum[x] = sum[x] + o;
    }
  }
  upd1(x, max(0ll, num), add);
  f[x][0] = tot + sum[x];
  upd1(x, max(0ll, num - 1), add);
  f[x][1] = tot + sum[x];
  for (long long i = 0; i < add.size(); i++)
    h[x].push(add[i]), sum[x] += add[i];
  for (long long i = 0; i < del.size(); i++) h[x].del(del[i]), sum[x] -= del[i];
}
int main() {
  n = read();
  long long ans = 0;
  for (long long i = 1; i < n; i++) {
    long long x = read(), y = read(), c = read();
    e[x].push_back({y, c});
    e[y].push_back({x, c});
    du[x]++;
    du[y]++;
    ans += c;
  }
  printf("%I64d ", ans);
  for (long long i = 1; i <= n; i++) {
    d[du[i]].push_back(i);
    sort(e[i].begin(), e[i].end(), cmp);
  }
  nxt[n] = n + 1;
  for (long long i = n - 1; i >= 1; i--) {
    if (d[i + 1].size())
      nxt[i] = i + 1;
    else
      nxt[i] = nxt[i + 1];
  }
  memset(vis, 0, sizeof(vis));
  for (long long u = 1; u < n; u++) {
    for (long long i = 0; i < d[u].size(); i++) dele(d[u][i]);
    ans = 0;
    D = u;
    for (long long i = u + 1; i < n; i = nxt[i])
      for (long long j = 0; j < d[i].size(); j++) {
        if (vis[d[i][j]]) continue;
        dfs(d[i][j]);
        ans = ans + f[d[i][j]][0];
      }
    for (long long i = u + 1; i < n; i = nxt[i])
      for (long long j = 0; j < d[i].size(); j++) vis[d[i][j]] = 0;
    printf("%I64d ", ans);
  }
  return 0;
}
