#include <bits/stdc++.h>
using namespace std;
const long long N = 250005;
long long n;
vector<pair<int, int> > e[N];
vector<long long> vec[N];
long long du[N];
bool cmp(pair<int, int> x, pair<int, int> y) {
  return du[x.first] < du[y.first];
}
long long nxt[N];
struct qq {
  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];
bool vis[N];
long long sum[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] = true;
  for (long long u = 0; u < e[x].size(); u++) {
    long long y = e[x][u].first, c = e[x][u].second;
    if (vis[y]) continue;
    h[y].push(c);
    sum[y] = sum[y] + c;
  }
}
long long f[N][2], D;
long long st[N];
void dfs(long long x) {
  vis[x] = true;
  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 u = st[x]; u < siz; u++) {
    long long y = e[x][u].first, c = e[x][u].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 u = 0; u < add.size(); u++) {
    h[x].push(add[u]), sum[x] += add[u];
  }
  for (long long u = 0; u < del.size(); u++) {
    h[x].del(del[u]), sum[x] -= del[u];
  }
}
int main() {
  scanf("%lld", &n);
  long long ans = 0;
  for (long long u = 1; u < n; u++) {
    long long x, y, c;
    scanf("%lld%lld%lld", &x, &y, &c);
    e[x].push_back({y, c});
    e[y].push_back({x, c});
    du[x]++;
    du[y]++;
    ans = ans + c;
  }
  printf("%lld ", ans);
  for (long long u = 1; u <= n; u++) {
    vec[du[u]].push_back(u);
    sort(e[u].begin(), e[u].end(), cmp);
  }
  nxt[n] = n + 1;
  for (long long u = n - 1; u >= 1; u--) {
    if (vec[u + 1].size())
      nxt[u] = u + 1;
    else
      nxt[u] = nxt[u + 1];
  }
  memset(vis, false, sizeof(vis));
  for (long long u = 1; u < n; u++) {
    for (long long i = 0; i < vec[u].size(); i++) dele(vec[u][i]);
    ans = 0;
    D = u;
    for (long long i = u + 1; i <= n; i = nxt[i])
      for (long long j = 0; j < vec[i].size(); j++) {
        if (vis[vec[i][j]] == true) continue;
        dfs(vec[i][j]);
        ans = ans + f[vec[i][j]][0];
      }
    for (long long i = u + 1; i <= n; i = nxt[i])
      for (long long j = 0; j < vec[i].size(); j++) vis[vec[i][j]] = false;
    printf("%lld ", ans);
  }
  return 0;
}
