#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(20020509);
char getc() {
  char c = getchar();
  while ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9'))
    c = getchar();
  return c;
}
int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); }
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return x * f;
}
int _, n, p[250010], degree[250010], root[250010], id[250010], t, cnt;
bool vis[250010];
long long f[250010][2], S[250010], a[250010];
struct data {
  int to, nxt, len;
} edge[250010 << 1];
struct data2 {
  int ch[2], p, size, x;
  long long sum;
} tree[250010 << 1];
void addedge(int x, int y, int z) {
  t++;
  edge[t].to = y, edge[t].nxt = p[x], edge[t].len = z, p[x] = t;
}
bool cmp(const int &a, const int &b) { return degree[a] < degree[b]; }
long long query(int k, int x, int s) {
  if (x == 0) return 0;
  if (k == 0) return x > s ? 10000000000000000ll : S[x];
  if (tree[tree[k].ch[0]].size >= x) return query(tree[k].ch[0], x, s);
  if (x - tree[tree[k].ch[0]].size > s)
    return query(tree[k].ch[1], x - tree[tree[k].ch[0]].size - 1, s) +
           tree[tree[k].ch[0]].sum + tree[k].x;
  long long t =
      tree[tree[k].ch[0]].sum + tree[k].x + S[x - tree[tree[k].ch[0]].size - 1];
  if (tree[k].x <= a[x - tree[tree[k].ch[0]].size])
    return t = min(t, tree[tree[k].ch[0]].sum + tree[k].x +
                          query(tree[k].ch[1], x - tree[tree[k].ch[0]].size - 1,
                                s));
  else
    return t = min(t, query(tree[k].ch[0], x, s));
  return t;
}
void up(int k) {
  tree[k].size = tree[tree[k].ch[0]].size + tree[tree[k].ch[1]].size + 1;
  tree[k].sum = tree[tree[k].ch[0]].sum + tree[tree[k].ch[1]].sum + tree[k].x;
}
void move(int &k, int p) {
  int t = tree[k].ch[p];
  tree[k].ch[p] = tree[t].ch[!p], tree[t].ch[!p] = k, up(k), up(t), k = t;
}
void ins(int &k, int x) {
  if (k == 0) {
    k = ++cnt;
    tree[k].p = rnd(), tree[k].size = 1, tree[k].sum = tree[k].x = x;
    return;
  }
  if (tree[k].x < x) {
    ins(tree[k].ch[1], x);
    if (tree[tree[k].ch[1]].p > tree[k].p) move(k, 1);
  } else {
    ins(tree[k].ch[0], x);
    if (tree[tree[k].ch[0]].p > tree[k].p) move(k, 0);
  }
  up(k);
}
void dfs(int k, int from) {
  vis[k] = 1;
  int x = 0;
  bool isroot = 1;
  f[k][0] = f[k][1] = 0;
  int last = 0;
  for (int i = p[k]; i; i = edge[i].nxt)
    if (degree[edge[i].to] > _) {
      if (!vis[edge[i].to])
        dfs(edge[i].to, k), f[k][0] += f[edge[i].to][1],
            f[k][1] += f[edge[i].to][1];
      else
        f[k][0] += edge[i].len, isroot = 0;
      last = i;
    } else if (last)
      edge[last].nxt = edge[i].nxt;
    else
      p[k] = edge[i].nxt;
  for (int i = p[k]; i; i = edge[i].nxt)
    if (degree[edge[i].to] > _ && edge[i].to != from)
      a[++x] = f[edge[i].to][0] - f[edge[i].to][1];
  sort(a + 1, a + x + 1);
  for (int i = 1; i <= x; i++) S[i] = S[i - 1] + a[i];
  for (int i = x; i >= 0; i--)
    if (a[i] <= 0) {
      if (degree[k] - i <= _)
        f[k][1] += S[i];
      else
        f[k][1] += query(root[k], degree[k] - _, x);
      break;
    }
  if (!isroot) {
    for (int i = x; i >= 0; i--)
      if (a[i] <= 0) {
        if (degree[k] - 1 - i <= _)
          f[k][0] += S[i];
        else
          f[k][0] += query(root[k], degree[k] - 1 - _, x);
        break;
      }
  }
}
signed main() {
  n = read();
  for (int i = 1; i < n; i++) {
    int x = read(), y = read(), z = read();
    addedge(x, y, z), addedge(y, x, z);
    degree[x]++, degree[y]++;
  }
  for (int i = 1; i <= n; i++) id[i] = i;
  sort(id + 1, id + n + 1, cmp);
  int x = 1;
  for (_ = 0; _ < n; _++) {
    while (x <= n && degree[id[x]] <= _) {
      for (int j = p[id[x]]; j; j = edge[j].nxt)
        ins(root[edge[j].to], edge[j].len);
      x++;
    }
    for (int j = x; j <= n; j++) vis[id[j]] = 0;
    long long ans = 0;
    for (int j = x; j <= n; j++)
      if (!vis[id[j]]) {
        dfs(id[j], id[j]);
        ans += f[id[j]][1];
      }
    printf("%I64d ", ans);
  }
  return 0;
}
