#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
void write__(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write__(x / 10);
  putchar(x % 10 + '0');
}
const int MAXN = 250005;
int n, deg[MAXN], X, vis[MAXN];
vector<pair<int, int> > G[MAXN];
pair<int, int> nd[MAXN];
bool cmp(pair<int, int> x, pair<int, int> y) {
  return deg[x.first] > deg[y.first];
}
multiset<long long> s[MAXN];
long long sum[MAXN], dp[MAXN][2];
void ins(int x, long long w) {
  s[x].insert(w);
  sum[x] += w;
}
void del(int x, long long w) {
  s[x].erase(s[x].find(w));
  sum[x] -= w;
}
void dfs(int u) {
  int num = deg[u] - X;
  num = max(num, 0);
  while (s[u].size() > num) del(u, *s[u].rbegin());
  vector<long long> ti, td;
  long long res = 0;
  for (int i = 0; i < (int)G[u].size(); ++i) {
    int v = G[u][i].first, w = G[u][i].second;
    if (deg[v] <= X) break;
    if (vis[v] == X) continue;
    vis[v] = X;
    dfs(v);
    if (dp[v][1] + w <= dp[v][0]) {
      num--;
      res += dp[v][1] + w;
    } else {
      ins(u, dp[v][1] + w - dp[v][0]);
      res += dp[v][0];
      ti.push_back(dp[v][1] + w - dp[v][0]);
    }
  }
  num = max(num, 0);
  while (s[u].size() > num)
    td.push_back(*s[u].rbegin()), del(u, *s[u].rbegin());
  dp[u][0] = res + sum[u];
  num = max(num - 1, 0);
  while (s[u].size() > num)
    td.push_back(*s[u].rbegin()), del(u, *s[u].rbegin());
  dp[u][1] = res + sum[u];
  for (int i = 0; i < (int)td.size(); ++i) ins(u, td[i]);
  for (int i = 0; i < (int)ti.size(); ++i) del(u, ti[i]);
}
int main() {
  ios::sync_with_stdio(0);
  n = read();
  long long ans = 0;
  for (int i = 1; i < n; ++i) {
    int u = read(), v = read(), w = read();
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w));
    deg[u]++;
    deg[v]++;
    ans += w;
  }
  write__(ans);
  putchar(' ');
  for (int i = 1; i <= n; ++i) sort(G[i].begin(), G[i].end(), cmp);
  for (int i = 1; i <= n; ++i) nd[i] = make_pair(deg[i], i);
  sort(nd + 1, nd + n + 1);
  int cur = 1;
  for (X = 1; X < n; ++X) {
    while (cur <= n && nd[cur].first == X) {
      int u = nd[cur].second;
      for (int i = 0; i < (int)G[u].size(); ++i) {
        if (deg[G[u][i].first] <= X) break;
        ins(G[u][i].first, G[u][i].second);
      }
      ++cur;
    }
    ans = 0;
    for (int i = cur; i <= n; ++i) {
      int u = nd[i].second;
      if (vis[u] != X) {
        vis[u] = X;
        dfs(u);
        ans += dp[u][0];
      }
    }
    write__(ans);
    putchar(' ');
  }
  puts("");
  return 0;
}
