#include <bits/stdc++.h>
using namespace std;
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n;
  cin >> n;
  long long all = 0;
  vector<vector<pair<int, int> > > adj(n);
  for (int i = 1; i < n; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    adj[--u].emplace_back(--v, w);
    adj[v].emplace_back(u, w);
    all += w;
  }
  vector<int> deg(n);
  for (int u = 0; u < n; u++) {
    deg[u] = adj[u].size();
  }
  for (int u = 0; u < n; u++) {
    sort(adj[u].begin(), adj[u].end(),
         [&](pair<int, int> &x, pair<int, int> &y) {
           return deg[x.first] < deg[y.first];
         });
  }
  vector<int> order(n);
  for (int i = 0; i < n; i++) {
    order[i] = i;
  }
  sort(order.begin(), order.end(),
       [&](int x, int y) { return deg[x] > deg[y]; });
  cout << all << " ";
  vector<int> idx(n), visit(n, -1);
  vector<multiset<int> > cost(n);
  vector<pair<long long, long long> > dp(n);
  vector<long long> base(n);
  for (int limit = 1; limit < n; limit++) {
    function<void(int, int)> dfs = [&](int u, int fa) {
      visit[u] = limit;
      while (idx[u] < deg[u] && deg[adj[u][idx[u]].first] <= limit) {
        base[u] += adj[u][idx[u]].second;
        cost[u].insert(adj[u][idx[u]].second);
        idx[u]++;
      }
      while (cost[u].size() > deg[u] - limit) {
        base[u] -= *cost[u].rbegin();
        cost[u].erase(--cost[u].end());
      }
      vector<int> add, del;
      long long sum = 0;
      for (int i = idx[u]; i < deg[u]; i++) {
        int v = adj[u][i].first;
        if (v != fa) {
          dfs(v, u);
          sum += dp[v].first;
          add.push_back(dp[v].second + adj[u][i].second - dp[v].first);
          base[u] += add.back();
          cost[u].insert(add.back());
        }
      }
      while (cost[u].size() > deg[u] - limit && *cost[u].rbegin() > 0) {
        del.push_back(*cost[u].rbegin());
        base[u] -= *cost[u].rbegin();
        cost[u].erase(--cost[u].end());
      }
      dp[u].first = dp[u].second = base[u] + sum;
      if (!cost[u].empty()) {
        dp[u].second -= max(0, *cost[u].rbegin());
      }
      for (int val : del) {
        cost[u].insert(val);
        base[u] += val;
      }
      for (int val : add) {
        cost[u].erase(cost[u].find(val));
        base[u] -= val;
      }
    };
    long long answer = 0;
    for (int u : order) {
      if (deg[u] <= limit) {
        break;
      }
      if (visit[u] != limit) {
        dfs(u, -1);
        answer += dp[u].first;
      }
    }
    cout << answer << " ";
  }
  cout << endl;
  return 0;
}
