#include <bits/stdc++.h>
using namespace std;
const long long N = 250005;
long long deg[N], sum[N], vis[N], f[N][2], a[N], X, n;
inline long long read() {
  long long x = 0, ff = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * ff;
}
vector<long long> ins, del;
vector<pair<long long, long long> > G[N];
multiset<long long> H[N];
inline void add(long long x, long long y, long long z) {
  G[x].push_back(make_pair(y, z));
  G[y].push_back(make_pair(x, z));
  deg[x]++;
  deg[y]++;
}
bool cmp(long long u, long long v) { return deg[u] < deg[v]; }
bool cmp2(pair<long long, long long> u, pair<long long, long long> v) {
  return deg[u.first] > deg[v.first];
}
inline void Del(long long x) {
  for (long long i = 0; i < G[x].size(); i++) {
    long long y = G[x][i].first;
    if (deg[y] <= X) break;
    H[y].insert(G[x][i].second);
    sum[y] += G[x][i].second;
    ;
  }
}
inline void dfs(long long x, long long fa) {
  long long need = deg[x] - X;
  long long res = 0;
  vis[x] = 1;
  while (H[x].size() && H[x].size() > need) {
    multiset<long long>::iterator it = H[x].end();
    --it;
    sum[x] -= (*it);
    H[x].erase(it);
  }
  for (long long i = 0; i < G[x].size(); i++) {
    long long y = G[x][i].first;
    if (y == fa) continue;
    if (deg[y] <= X) break;
    dfs(y, x);
  }
  ins.clear();
  del.clear();
  for (long long i = 0; i < G[x].size(); i++) {
    long long y = G[x][i].first;
    if (y == fa) continue;
    if (deg[y] <= X) break;
    long long now = f[y][1] + G[x][i].second - f[y][0];
    if (now <= 0) {
      --need;
      res += f[y][1] + G[x][i].second;
      continue;
    }
    H[x].insert(now);
    sum[x] += now;
    del.push_back(now);
    res += f[y][0];
  }
  while (H[x].size() && H[x].size() > need) {
    multiset<long long>::iterator it = H[x].end();
    --it;
    sum[x] -= (*it);
    ins.push_back(*it);
    H[x].erase(it);
  }
  f[x][0] = sum[x] + res;
  while (H[x].size() && H[x].size() > need - 1) {
    multiset<long long>::iterator it = H[x].end();
    --it;
    sum[x] -= (*it);
    ins.push_back(*it);
    H[x].erase(it);
  }
  f[x][1] = sum[x] + res;
  for (long long i = 0; i < ins.size(); i++)
    H[x].insert(ins[i]), sum[x] += ins[i];
  for (long long i = 0; i < del.size(); i++) {
    multiset<long long>::iterator it = H[x].find(del[i]);
    if (it == H[x].end()) continue;
    sum[x] -= del[i];
    H[x].erase(it);
  }
}
signed main() {
  n = read();
  long long Ret = 0;
  for (long long i = 1; i < n; i++) {
    long long u, v, w;
    u = read();
    v = read();
    w = read();
    add(u, v, w);
    Ret += w;
  }
  for (long long i = 1; i <= n; i++) a[i] = i;
  sort(a + 1, a + n + 1, cmp);
  for (long long i = 1; i <= n; i++) {
    sort(G[i].begin(), G[i].end(), cmp2);
  }
  printf("%lld ", Ret);
  long long pos = 1;
  for (long long i = 1; i < n; i++) {
    X = i;
    while (deg[a[pos]] <= i && pos <= n) Del(a[pos]), ++pos;
    long long Ans = 0;
    for (long long j = pos; j <= n; j++) vis[a[j]] = 0;
    for (long long j = pos; j <= n; j++) {
      if (vis[a[j]]) continue;
      dfs(a[j], 0);
      Ans = Ans + f[a[j]][0];
    }
    printf("%lld ", Ans);
  }
  return 0;
}
