#include <bits/stdc++.h>
using namespace std;
int d[250005], n, X, vis[250005];
vector<pair<int, int> > e[250005];
struct deleted_heap {
  priority_queue<long long> val, del;
  long long sm;
  deleted_heap() { sm = 0; }
  void update() {
    while (del.size())
      if (val.top() == del.top())
        val.pop(), del.pop();
      else
        break;
  }
  void push(long long x) {
    sm += x;
    val.push(x);
    update();
  }
  void pop() {
    sm -= val.top();
    val.pop();
    update();
  }
  void erase(long long x) {
    sm -= x;
    del.push(x);
    update();
  }
  int top() { return val.top(); }
  int size() { return val.size() - del.size(); }
  inline void Print() {
    vector<long long> tmp;
    while (size()) tmp.push_back(top()), pop();
    for (int x : tmp) printf("%d ", x), push(x);
    puts("\n-----");
  }
} H[250005];
inline void die(int u) {
  for (auto x : e[u]) {
    if (d[x.first] <= X) break;
    H[x.first].push(x.second);
  }
}
vector<long long> tmp, del;
long long dp[250005][2];
void dfs(int u, int fa) {
  vis[u] = X;
  int rest = d[u] - X;
  long long ans = 0;
  for (; H[u].size() > rest;) H[u].pop();
  for (auto v : e[u])
    if (v.first != fa) {
      if (d[v.first] <= X) break;
      dfs(v.first, u);
    }
  tmp.clear();
  del.clear();
  for (auto v : e[u])
    if (v.first != fa) {
      if (d[v.first] <= X) break;
      long long tmp = dp[v.first][1] + v.second - dp[v.first][0];
      if (tmp <= 0)
        rest--, ans += dp[v.first][1] + v.second;
      else
        ans += dp[v.first][0], del.push_back(tmp), H[u].push(tmp);
    }
  for (; H[u].size() && H[u].size() > rest; H[u].pop())
    tmp.push_back(H[u].top());
  dp[u][0] = ans + H[u].sm;
  for (; H[u].size() && H[u].size() > rest - 1; H[u].pop())
    tmp.push_back(H[u].top());
  dp[u][1] = ans + H[u].sm;
  for (long long x : tmp) H[u].push(x);
  for (long long x : del) H[u].erase(x);
}
pair<int, int> D[250005];
bool cmp(pair<int, int> x, pair<int, int> y) { return d[x.first] > d[y.first]; }
int main() {
  long long sum = 0;
  scanf("%d", &n);
  for (int i = 1, u, v, w; i < n; i++)
    scanf("%d%d%d", &u, &v, &w), e[u].emplace_back(v, w),
        e[v].emplace_back(u, w), d[u]++, d[v]++, sum += w;
  printf("%lld ", sum);
  for (int i = 1; i <= n; i++)
    D[i] = pair<int, int>(d[i], i), sort(e[i].begin(), e[i].end(), cmp);
  sort(D + 1, D + 1 + n);
  int cur = 1;
  for (X = 1; X < n; X++) {
    for (; cur <= n && D[cur].first == X;) die(D[cur].second), cur++;
    long long ans = 0;
    for (int j = cur; j <= n; j++)
      if (vis[D[j].second] != X) {
        dfs(D[j].second, 0);
        ans += dp[D[j].second][0];
      }
    printf("%lld ", ans);
  }
  return 0;
}
