#include <bits/stdc++.h>
const int M = 250005;
const long long INF = 1e16;
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0, w = 1;
  while (c > '9' || c < '0') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * w;
}
int vis[M];
int n, num, hea[M];
int d[M], pi[M], fdis[M], fa[M];
int Tag, dmx, rt[M];
long long ans, f[M][2];
struct Node {
  int v, w;
};
inline bool operator<(Node A, Node B) { return d[A.v] > d[B.v]; }
vector<Node> vec[M];
inline bool cmp(int a, int b) { return d[a] < d[b]; }
inline void add_edge(int u, int v, int w) { vec[u].push_back((Node){v, w}); }
void fdfs(int u, int father) {
  fa[u] = father;
  for (int i = 0, v, w, sz = vec[u].size(); i < sz; i++) {
    v = vec[u][i].v, w = vec[u][i].w;
    if (v == father) continue;
    fdis[v] = w;
    fdfs(v, u);
  }
}
namespace fhq {
int tot;
long long sum[M * 8], val[M * 8];
int size[M * 8], pos[M * 8], son[M * 8][2];
inline int New(long long w) {
  size[++tot] = 1;
  pos[tot] = rand();
  sum[tot] = w;
  val[tot] = w;
  return tot;
}
inline void pushup(int now) {
  size[now] = size[(son[now][0])] + size[(son[now][1])] + 1;
  sum[now] = sum[(son[now][0])] + sum[(son[now][1])] + val[now];
}
int Merge(int x, int y) {
  if (!x || !y) return x + y;
  if (pos[x] < pos[y]) {
    son[x][1] = Merge(son[x][1], y);
    pushup(x);
    return x;
  } else {
    son[y][0] = Merge(x, son[y][0]);
    pushup(y);
    return y;
  }
}
void Split(int now, long long k, int &x, int &y) {
  if (!now) return (void)(x = y = 0);
  if (val[now] <= k) {
    x = now;
    Split((son[now][1]), k, (son[now][1]), y);
  } else {
    y = now;
    Split((son[now][0]), k, x, (son[now][0]));
  }
  pushup(now);
}
inline void Insert(int &root, long long w) {
  int x, y;
  Split(root, w, x, y);
  root = Merge(Merge(x, New(w)), y);
}
inline void Del(int &root, long long w) {
  int x, y, z;
  Split(root, w, x, z);
  Split(x, w - 1, x, y);
  y = Merge(son[y][0], son[y][1]);
  root = Merge(Merge(x, y), z);
}
inline long long Rnk_val(int now, int k) {
  while (1) {
    if (k <= size[(son[now][0])])
      now = (son[now][0]);
    else if (k == size[(son[now][0])] + 1)
      return val[now];
    else
      k -= size[(son[now][0])] + 1, now = (son[now][1]);
  }
}
inline long long Kth_Sum(int now, int k) {
  if (!k) return 0;
  long long ret = 0;
  while (1) {
    if (k <= size[(son[now][0])])
      now = (son[now][0]);
    else if (k == size[(son[now][0])] + 1) {
      ret += sum[(son[now][0])] + val[now];
      return ret;
    } else {
      ret += sum[(son[now][0])] + val[now];
      k -= size[(son[now][0])] + 1;
      now = (son[now][1]);
    }
  }
}
}  // namespace fhq
void dfs(int u, int father) {
  vis[u] = Tag;
  f[u][0] = f[u][1] = 0;
  if (d[u] <= Tag) return;
  for (int i = 0, v, w, sz = vec[u].size(); i < sz; i++) {
    v = vec[u][i].v, w = vec[u][i].w;
    if (v == father) continue;
    dfs(v, u);
    f[u][0] += f[v][0];
    f[u][1] += f[v][0];
    fhq::Insert(rt[u], f[v][1] + w - f[v][0]);
  }
  int cnt = 0;
  long long x, y, v;
  int l = 1, r = fhq::size[rt[u]], ret = 0, mid;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (fhq::Rnk_val(rt[u], mid) < 0)
      ret = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  if (ret <= d[u] - Tag)
    f[u][0] += fhq::Kth_Sum(rt[u], d[u] - Tag);
  else
    f[u][0] += fhq::Kth_Sum(rt[u], ret);
  if (ret <= d[u] - Tag - 1)
    f[u][1] += fhq::Kth_Sum(rt[u], d[u] - Tag - 1);
  else
    f[u][1] += fhq::Kth_Sum(rt[u], ret);
  for (int i = 0, v, w, sz = vec[u].size(); i < sz; i++) {
    v = vec[u][i].v, w = vec[u][i].w;
    if (v == father) continue;
    fhq::Del(rt[u], f[v][1] + w - f[v][0]);
  }
}
int main() {
  n = read();
  for (int i = 1, u, v, w; i < n; i++) {
    u = read();
    v = read();
    w = read();
    add_edge(u, v, w);
    add_edge(v, u, w);
    ++d[u];
    ++d[v];
    ans += w;
  }
  fdfs(1, 0);
  for (int i = 1; i <= n; i++) {
    pi[i] = i;
    dmx = max(dmx, d[i]);
    sort(vec[i].begin(), vec[i].end());
  }
  sort(pi + 1, pi + n + 1, cmp);
  printf("%lld ", ans);
  for (int x = 1, Now = 1; x < n; x++) {
    Tag = x;
    ans = 0;
    while (Now < n && d[pi[Now]] <= x) {
      f[pi[Now]][0] = 0;
      f[pi[Now]][1] = 0;
      ++Now;
    }
    for (int j = Now; j <= n; j++) {
      int v;
      while (!vec[pi[j]].empty()) {
        v = vec[pi[j]][vec[pi[j]].size() - 1].v;
        if (d[v] <= x) {
          if (pi[j] == fa[v]) fhq::Insert(rt[pi[j]], fdis[v]);
          vec[pi[j]].pop_back();
        } else
          break;
      }
    }
    for (int j = Now, u; j <= n; j++)
      if (vis[pi[j]] != x) {
        u = pi[j];
        while (fa[u] && d[fa[u]] > x) u = fa[u];
        dfs(u, 0);
        ans += min(fdis[u] > 0 ? f[u][1] + fdis[u] : INF, f[u][0]);
      }
    printf("%lld ", ans);
  }
  return 0;
}
