#include <bits/stdc++.h>
using namespace std;
struct node {
  long long x, y;
  int id;
  bool operator<(const node &a) const {
    if (a.y != y) return y < a.y;
    return id < a.id;
  }
};
const int maxn = 3e5 + 100;
set<node> q[maxn], limt[maxn];
set<pair<int, int> > v[maxn];
int vis[maxn], tag[maxn];
long long dp[maxn][2];
long long sum[maxn], sum2[maxn];
long long cal(set<node> s, int x, int id) {
  long long ret = sum2[id];
  set<node> path;
  for (auto &u : s) {
    limt[id].insert(u);
    ret += u.y;
  }
  while (limt[id].size() > 0 && limt[id].size() > x) {
    if (limt[id].rbegin()->y < 0) break;
    path.insert(*limt[id].rbegin());
    ret -= limt[id].rbegin()->y;
    limt[id].erase(--limt[id].end());
  }
  for (auto &u : s) {
    path.erase(u);
    limt[id].erase(u);
  }
  for (auto &u : path) limt[id].insert(u);
  return ret;
}
pair<long long, int> dfs(int x, int k) {
  if (tag[x] || vis[x]) return {0, 0};
  tag[x] = 1;
  set<node> tp;
  long long s = sum[x];
  for (auto &u : v[x]) {
    auto ok = dfs(u.first, k);
    if (ok.second) {
      tp.insert({dp[u.first][0], dp[u.first][1] + u.second - dp[u.first][0],
                 u.first});
    }
  }
  int sz = q[x].size() + tp.size();
  while (limt[x].size() && limt[x].size() > sz - k + 1) {
    if (limt[x].rbegin()->y < 0) break;
    sum2[x] -= limt[x].rbegin()->y;
    limt[x].erase(--limt[x].end());
  }
  for (auto &u : tp) s += u.x;
  dp[x][1] = s + cal(tp, sz - k, x);
  dp[x][0] = s + cal(tp, sz - k + 1, x);
  return {dp[x][1], 1};
}
int sz[maxn], id[maxn];
void init(int n) {
  for (int i = 0; i < n + 10; ++i) {
    sz[i] = 0;
    vis[i] = tag[i] = 0;
    q[i].clear();
    v[i].clear();
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  double c = clock();
  int t = 1;
  while (t--) {
    int n, ks;
    cin >> n;
    init(n);
    long long sum = 0;
    for (int i = 1; i < n; ++i) {
      int x, y, z;
      cin >> x >> y >> z;
      v[x].insert({y, z});
      v[y].insert({x, z});
      sz[x]++, sz[y]++;
      sum += z;
    }
    for (int i = 1; i <= n; ++i) id[i] = i;
    sort(id + 1, id + n + 1,
         [&](const int &i, const int &j) { return sz[i] < sz[j]; });
    cout << sum;
    for (int i = 1, p = 1; i < n; ++i) {
      while (p <= n && sz[id[p]] <= i) {
        vis[id[p]] = 1;
        for (auto &u : v[id[p]]) {
          q[u.first].insert({0, u.second, id[p]});
          sum2[u.first] += u.second;
          limt[u.first].insert({0, u.second, id[p]});
          v[u.first].erase({id[p], u.second});
        }
        v[id[p]].clear();
        p++;
      }
      long long ans = 0;
      for (int j = p; j <= n; ++j) {
        ans += dfs(id[j], i).first;
      }
      cout << ' ' << ans;
      for (int j = p; j <= n; ++j) tag[id[j]] = 0;
    }
    cout << "\n";
  }
  return 0;
}
