#include <bits/stdc++.h>
using namespace std;
int q[2 * 250005], f[250005], t[2 * 250005], v[2 * 250005], di[250005],
    u[250005], tot;
multiset<int> one[250005], two[250005];
long long sum[250005], dp[250005][2], tmp[250005], max_value, ans[250005];
int dl[250005], in[250005], timestamp, vis[250005];
vector<int> go[250005], va[250005];
int x, y, z, D, n, now;
void link(int x, int y, int z) {
  q[++tot] = f[x];
  t[tot] = y;
  f[x] = tot;
  v[tot] = z;
  di[x]++;
}
bool cmpd(const int &a, const int &b) { return di[a] > di[b]; }
void adjust_12(int x) {
  multiset<int>::iterator it;
  while (one[x].size() > di[x] - D) {
    it = one[x].end();
    it--;
    sum[x] -= *it;
    two[x].insert(*it);
    one[x].erase(it);
  }
}
void adjust_21(int x) {
  multiset<int>::iterator it;
  while (one[x].size() < di[x] - D && two[x].size() > 0) {
    it = two[x].begin();
    sum[x] += *it;
    one[x].insert(*it);
    two[x].erase(it);
  }
}
void add_2(int x, int y, int z) {
  go[x].push_back(y);
  va[x].push_back(z);
  go[y].push_back(x);
  va[y].push_back(z);
}
void add_1(int x, int y) {
  one[x].insert(y);
  sum[x] += y;
  adjust_12(x);
}
void remove_1(int x, int y) {
  if (one[x].find(y) != one[x].end()) {
    sum[x] -= y;
    one[x].erase(one[x].find(y));
    adjust_21(x);
  } else
    two[x].erase(two[x].find(y));
}
void dfs(int x, int y) {
  vis[x] = timestamp;
  int m = go[x].size();
  int ned = di[x] - D;
  int has = 0;
  int now;
  for (int i = 0; i < m; i++)
    if (go[x][i] != y) dfs(go[x][i], x);
  tmp[0] = 0;
  for (int i = 0; i < m; i++)
    if (go[x][i] != y) {
      now = go[x][i];
      tmp[0] += dp[now][0];
      tmp[++has] = dp[now][1] + va[x][i] - dp[now][0];
    }
  sort(tmp + 1, tmp + 1 + has);
  for (int i = 1; i <= has; i++) tmp[i] += tmp[i - 1];
  int res = one[x].size();
  int cl;
  for (int tp = 0; tp < 2; tp++) {
    cl = 0;
    int need = ned - tp;
    multiset<int>::iterator it;
    int qd = need - res;
    if (qd < 0) {
      it = one[x].end();
      it--;
      sum[x] -= *it;
      dp[x][tp] = sum[x] + tmp[0];
      dl[++cl] = *it;
      one[x].erase(it);
      qd = 0;
    } else {
      if (qd > has)
        dp[x][tp] = max_value;
      else
        dp[x][tp] = tmp[qd] + sum[x];
    }
    for (int i = qd + 1; i <= has; i++)
      if (one[x].size() > 0) {
        it = one[x].end();
        it--;
        sum[x] -= *it;
        dp[x][tp] = min(dp[x][tp], tmp[i] + sum[x]);
        dl[++cl] = *it;
        one[x].erase(it);
      } else
        dp[x][tp] = min(dp[x][tp], tmp[i]);
    for (int i = 1; i <= cl; i++) sum[x] += dl[i], one[x].insert(dl[i]);
  }
}
int main() {
  max_value = (long long)250005 * 1000000;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d %d %d", &x, &y, &z);
    link(x, y, z);
    link(y, x, z);
  }
  for (int i = 1; i <= n; i++) u[i] = i;
  sort(u + 1, u + 1 + n, cmpd);
  now = 0;
  for (D = n - 1; D >= 0; D--) {
    for (int i = 1; i <= now; i++) adjust_21(u[i]);
    while (now < n && di[u[now + 1]] > D) {
      now++;
      x = u[now];
      in[x] = 1;
      for (int i = f[x]; i; i = q[i]) {
        y = t[i];
        if (!in[y])
          add_1(x, v[i]);
        else
          remove_1(y, v[i]), add_2(x, y, v[i]);
      }
    }
    timestamp++;
    for (int i = 1; i <= now; i++)
      if (vis[u[i]] != timestamp) {
        dfs(u[i], 0);
        ans[D] += dp[u[i]][0];
      }
  }
  for (int D = 0; D < n; D++) printf("%I64d\n", ans[D]);
  return 0;
}
