#include <bits/stdc++.h>
using namespace std;
const int N = 250010;
inline int read() {
  int res = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch <= '9' && ch >= '0'; ch = getchar())
    res = (res << 1) + (res << 3) + (ch ^ '0');
  return res;
}
int n, k, head[N], deg[N], vis[N], ord[N];
long long f[N][2], sum[N];
struct data {
  int to, len;
};
vector<data> edge[N];
bool cmp(data x, data y) { return deg[x.to] > deg[y.to]; }
bool cmp1(int x, int y) { return deg[x] < deg[y]; }
struct node {
  priority_queue<long long, vector<long long>, greater<long long> > s;
  priority_queue<long long> h;
  long long tot;
} q[N];
vector<long long> tmp, del;
void dfs(int u, int fa, int len, int x) {
  f[u][1] = 1ll * len + sum[u];
  f[u][0] = sum[u];
  vis[u] = x;
  while (q[u].h.size() < x - 1 && !q[u].s.empty())
    q[u].h.push(q[u].s.top()), q[u].tot += q[u].s.top(), q[u].s.pop();
  while (q[u].h.size() && q[u].s.size() && q[u].h.top() > q[u].s.top()) {
    long long H = q[u].h.top();
    q[u].h.pop();
    long long S = q[u].s.top();
    q[u].s.pop();
    q[u].tot += S - H;
    q[u].h.push(S);
    q[u].s.push(H);
  }
  int sz = edge[u].size();
  for (auto nxt : edge[u]) {
    int v = nxt.to;
    if (v == fa) continue;
    if (deg[v] <= x) break;
    dfs(v, u, nxt.len, x);
  }
  tmp.clear();
  for (auto nxt : edge[u]) {
    int v = nxt.to;
    if (v == fa) continue;
    if (deg[v] <= x) break;
    f[u][0] += f[v][1];
    f[u][1] += f[v][1];
    if (f[v][1] > f[v][0]) tmp.push_back(f[v][0] - f[v][1]);
  }
  sort(tmp.begin(), tmp.end());
  int now = 0, cnt = -1;
  sz = tmp.size();
  del.clear();
  long long res = q[u].tot;
  for (int i = 0; i < max(0, min((int)(x - 1 - q[u].h.size()), sz)); i++)
    res += tmp[i];
  cnt = max((int)(x - 1 - q[u].h.size() - 1), -1);
  while (!q[u].h.empty() && cnt < sz - 1 && tmp[cnt + 1] < q[u].h.top())
    cnt++, res += tmp[cnt] - q[u].h.top(), del.push_back(q[u].h.top()),
        q[u].h.pop();
  f[u][0] += res;
  long long nxt = 1e15;
  if (del.size()) nxt = min(nxt, del[del.size() - 1]);
  if (cnt < sz - 1) nxt = min(nxt, tmp[cnt + 1]);
  if (!q[u].s.empty()) nxt = min(nxt, q[u].s.top());
  f[u][1] += res + min(0ll, nxt);
  for (auto nxt : del) q[u].h.push(nxt);
}
int main() {
  n = read();
  long long tot = 0;
  for (int i = 1, x, y, z; i < n; i++) {
    x = read();
    y = read();
    z = read();
    tot += 1ll * z;
    deg[x]++;
    deg[y]++;
    edge[x].push_back((data){y, z});
    edge[y].push_back((data){x, z});
  }
  for (int i = 1; i <= n; i++) sort(edge[i].begin(), edge[i].end(), cmp);
  for (int i = 1; i <= n; i++) ord[i] = i;
  sort(ord + 1, ord + n + 1, cmp1);
  printf("%lld ", tot);
  int now = 1;
  for (int i = 1; i < n; i++) {
    while (deg[ord[now]] <= i && now <= n) {
      int u = ord[now];
      int tmp = edge[u].size();
      for (auto nxt : edge[u]) {
        int v = nxt.to;
        if (deg[v] <= i) break;
        q[v].s.push(1ll * (-nxt.len));
        sum[v] += 1ll * nxt.len;
      }
      now++;
    }
    long long res = 0;
    int st = now;
    for (int j = st; j <= n; j++) {
      int u = ord[j];
      if (vis[u] != i) dfs(u, u, 0, i), res += f[u][1];
    }
    printf("%lld ", res);
  }
}
