#include <bits/stdc++.h>
using namespace std;
const int N = 250005;
long long ans, sum[N], f[N][2];
vector<pair<long long, long long> > G[N << 1];
pair<long long, long long> d[N];
multiset<long long> H[N];
void insert(int x, long long val) { H[x].insert(val); }
void erase(long long x, long long val) {
  multiset<long long>::iterator it = H[x].lower_bound(val);
  H[x].erase(it);
}
bool vis[N];
long long Max, du[N], n;
void die(long long x) {
  for (long long i = 0; i < G[x].size(); i++) {
    long long y = G[x][i].second;
    if (du[y] <= Max) break;
    insert(y, G[x][i].first);
    sum[y] += G[x][i].first;
  }
}
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return du[a.second] > du[b.second];
}
vector<long long> ins, del;
void dfs(int x, int fa) {
  vis[x] = 1;
  long long m = du[x] - Max;
  while (H[x].size() && H[x].size() > m) {
    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].second;
    if (y == fa) continue;
    if (du[y] <= Max) break;
    dfs(y, x);
  }
  ins.clear();
  del.clear();
  long long Ans = 0;
  for (int i = 0; i < G[x].size(); i++) {
    int y = G[x][i].second;
    if (y == fa) continue;
    if (du[y] <= Max) break;
    long long val = f[y][1] + G[x][i].first - f[y][0];
    if (val <= 0) {
      Ans += f[y][1] + G[x][i].first;
      m--;
      continue;
    }
    insert(x, val);
    del.push_back(val);
    Ans += f[y][0];
    sum[x] += val;
  }
  while (H[x].size() && H[x].size() > m) {
    multiset<long long>::iterator it = H[x].end();
    --it;
    sum[x] -= *it, ins.push_back(*it), H[x].erase(it);
  }
  f[x][0] = Ans + sum[x];
  while (H[x].size() && H[x].size() > m - 1) {
    multiset<long long>::iterator it = H[x].end();
    --it;
    sum[x] -= *it, ins.push_back(*it), H[x].erase(it);
  }
  f[x][1] = Ans + sum[x];
  for (long long i = 0; i < ins.size(); i++)
    insert(x, ins[i]), sum[x] += ins[i];
  for (long long i = 0; i < del.size(); i++) erase(x, del[i]), sum[x] -= del[i];
}
int main() {
  scanf("%lld", &n);
  for (int i = 1, a, b, c; i < n; i++) {
    scanf("%lld%lld%lld", &a, &b, &c);
    ans += c;
    G[a].push_back(pair<long long, long long>(c, b));
    G[b].push_back(pair<long long, long long>(c, a));
    du[a]++;
    du[b]++;
  }
  for (int i = 1; i <= n; i++) {
    d[i] = pair<long long, long long>(du[i], i);
    sort(G[i].begin(), G[i].end(), cmp);
  }
  sort(d + 1, d + 1 + n);
  printf("%lld ", ans);
  long long pos = 1;
  for (Max = 1; Max < n; Max++) {
    while (pos <= n && d[pos].first <= Max) die(d[pos].second), ++pos;
    ans = 0;
    memset(vis, 0, sizeof(vis));
    for (int j = pos; j <= n; j++) {
      if (vis[d[j].second]) continue;
      dfs(d[j].second, 0);
      ans += f[d[j].second][0];
    }
    printf("%lld ", ans);
  }
  printf("\n");
  return 0;
}
