#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
int d[500011];
struct apple {
  int v, l;
  bool operator<(const apple &other) const { return d[v] > d[other.v]; }
} temp;
vector<apple> V[500011];
vector<long long> D[500011], R[500011];
set<int> Root;
set<int>::iterator it;
priority_queue<int> Q[500011];
int n, m, fa[500011], Mark[500011], tmp_root[500011];
long long dp[500011][2], ans[500011], All;
struct Deletable_Priority_Queue {
  priority_queue<long long, vector<long long>, greater<long long> > pq, del;
  long long sum;
  int num;
  void push(long long x) { pq.push(x), num++, sum += x; }
  void Delete(long long x) { del.push(x), num--, sum -= x; }
  void pop() { sum -= pq.top(), pq.pop(), num--; }
  long long top() {
    while (!pq.empty() && !del.empty() && pq.top() == del.top())
      pq.pop(), del.pop();
    return pq.top();
  }
} A[500011];
void basic_dfs(int u, int f) {
  fa[u] = f;
  int len = V[u].size();
  for (int i = 0; i < len; i++) {
    int y = V[u][i].v;
    if (y != f) {
      basic_dfs(y, u);
    }
  }
}
void dfs(int x, int lim) {
  dp[x][0] = dp[x][1] = 0;
  int len = V[x].size(), y, l, num = lim;
  for (int i = 0; i < len; i++) {
    y = V[x][i].v;
    l = V[x][i].l;
    if (d[y] < lim) break;
    if (y == fa[x]) continue;
    dfs(y, lim);
    long long temp = dp[y][0] - dp[y][1] + l;
    dp[x][0] += dp[y][1];
    dp[x][1] += dp[y][1];
    if (temp < 0) {
      continue;
    }
    A[x].push(temp);
    D[x].push_back(temp);
  }
  while (A[x].num && A[x].num > num) {
    R[x].push_back(A[x].top());
    A[x].pop();
  }
  dp[x][1] += A[x].sum;
  while (A[x].num && A[x].num > num - 1) {
    R[x].push_back(A[x].top());
    A[x].pop();
  }
  dp[x][0] += A[x].sum;
  len = R[x].size();
  for (int i = 0; i < len; i++) A[x].push(R[x][i]);
  R[x].clear();
  len = D[x].size();
  for (int i = 0; i < len; i++) A[x].Delete(D[x][i]);
  D[x].clear();
  len = V[x].size();
  for (int i = 0; i < len; i++) {
    y = V[x][i].v;
    l = V[x][i].l;
    if (y == fa[x]) continue;
    if (d[y] < lim) break;
    if (d[y] == lim) {
      Q[x].push(l);
    }
  }
  while (A[x].num <= lim && !Q[x].empty()) {
    A[x].push(Q[x].top());
    Q[x].pop();
  }
  while (!Q[x].empty() && A[x].num && Q[x].top() > A[x].top()) {
    Q[x].push(A[x].top());
    A[x].Delete(A[x].top());
    A[x].push(Q[x].top());
    Q[x].pop();
  }
  if (d[x] == lim) {
    if (Mark[x]) Root.erase(x);
    for (int i = 0; i < len; i++) {
      y = V[x][i].v;
      l = V[x][i].l;
      if (y == fa[x]) continue;
      if (d[y] <= lim) break;
      Mark[y] = 1;
      Root.insert(y);
      A[y].push(l);
    }
    while (A[x].num) {
      All += A[x].top();
      A[x].pop();
    }
    while (!Q[x].empty()) {
      All += Q[x].top();
      Q[x].pop();
    }
  }
}
int main() {
  int x, y, z;
  long long tmp = 0;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d%d", &x, &y, &z);
    tmp += z;
    d[x]++;
    d[y]++;
    temp.v = y;
    temp.l = z;
    V[x].push_back(temp);
    temp.v = x;
    temp.l = z;
    V[y].push_back(temp);
  }
  for (int i = 1; i <= n; i++) {
    sort(V[i].begin(), V[i].end());
  }
  basic_dfs(1, 0);
  Root.insert(1);
  Mark[1] = 1;
  ans[0] = tmp;
  for (int i = 1; i < n; i++) {
    int cnt = 1;
    for (it = Root.begin(); it != Root.end(); it++, cnt++) tmp_root[cnt] = *it;
    cnt--;
    ans[i] = tmp - All;
    for (int j = 1; j <= cnt; j++) {
      dfs(tmp_root[j], i);
      ans[i] -= dp[tmp_root[j]][1];
    }
  }
  for (int i = 0; i < n; i++) printf("%lld ", ans[i]);
  return 0;
}
