#include <bits/stdc++.h>
using namespace std;
const int N = 2.5e5 + 7;
int n, lim, d[N], vis[N];
vector<pair<int, int> > g[N];
pair<int, int> p[N];
multiset<long long> s[N];
vector<long long> ins, del;
long long sum[N], dp[N][2];
bool cmp(pair<int, int>& a, pair<int, int>& b) {
  return d[a.second] > d[b.second];
}
void die(int u) {
  for (auto& pr : g[u]) {
    int v = pr.second, w = pr.first;
    if (d[v] <= lim) break;
    s[v].insert(w), sum[v] += w;
  }
}
void dfs(int u, int f) {
  vis[u] = lim;
  int cnt = d[u] - lim;
  while ((int)s[u].size() > cnt) {
    auto it = s[u].end();
    it--;
    sum[u] -= *it;
    s[u].erase(it);
  }
  for (auto& pr : g[u]) {
    int v = pr.second, w = pr.first;
    if (v == f) continue;
    if (d[v] <= lim) break;
    dfs(v, u);
  }
  ins.clear(), del.clear();
  long long ans = 0;
  for (auto& pr : g[u]) {
    int v = pr.second, w = pr.first;
    if (v == f) continue;
    if (d[v] <= lim) break;
    long long val = dp[v][1] + w - dp[v][0];
    if (val <= 0) {
      ans += dp[v][1] + w, cnt--;
      continue;
    }
    s[u].insert(val), sum[u] += val;
    del.push_back(val);
    ans += dp[v][0];
  }
  while (s[u].size() && (int)s[u].size() > cnt) {
    auto it = s[u].end();
    it--;
    sum[u] -= *it;
    ins.push_back(*it);
    s[u].erase(it);
  }
  dp[u][0] = ans + sum[u];
  while (s[u].size() && (int)s[u].size() > cnt - 1) {
    auto it = s[u].end();
    it--;
    sum[u] -= *it;
    ins.push_back(*it);
    s[u].erase(it);
  }
  dp[u][1] = ans + sum[u];
  for (auto& x : ins) s[u].insert(x), sum[u] += x;
  for (auto& x : del) s[u].erase(s[u].find(x)), sum[u] -= x;
}
int main(void) {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  long long ans = 0;
  for (int i = 1; i < n; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    g[u].push_back(make_pair(w, v));
    g[v].push_back(make_pair(w, u));
    d[u]++, d[v]++;
    ans += w;
  }
  for (int i = 1; i <= n; ++i) {
    sort(g[i].begin(), g[i].end(), cmp);
    p[i] = make_pair(d[i], i);
  }
  sort(p + 1, p + n + 1);
  cout << ans << ' ';
  int pos = 1;
  for (lim = 1; lim < n; ++lim) {
    while (pos <= n && p[pos].first <= lim) die(p[pos++].second);
    ans = 0;
    for (int i = pos; i <= n; ++i) {
      if (vis[p[i].second] < lim) {
        dfs(p[i].second, 0);
        ans += dp[p[i].second][0];
      }
    }
    cout << ans << ' ';
  }
  return 0;
}
