#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
inline int read() {
  int s = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return s;
}
vector<pair<int, int> > G[N];
int n, x;
int deg[N], ver[N], vis[N];
long long f[N][2], val[N], sum;
multiset<long long> s[N];
inline void ins(int u, long long x) {
  val[u] += x;
  s[u].insert(x);
}
inline void era(int u, long long x) {
  val[u] -= x;
  s[u].erase(s[u].find(x));
}
inline void del(int u) {
  for (auto &[v, w] : G[u]) {
    if (deg[v] <= x) break;
    ins(v, w);
  }
}
void dfs(int u, int fa) {
  vis[u] = x;
  int cnt = deg[u] - x;
  while ((int)s[u].size() && (int)s[u].size() > cnt) era(u, *(--s[u].end()));
  for (auto &[v, w] : G[u]) {
    if (v == fa) continue;
    if (deg[v] <= x) break;
    dfs(v, u);
  }
  vector<long long> tmp, del;
  long long res = 0;
  for (auto &[v, w] : G[u]) {
    if (v == fa) continue;
    if (deg[v] <= x) break;
    long long x = f[v][1] + w - f[v][0];
    if (x <= 0) {
      cnt--, res += f[v][1] + w;
      continue;
    }
    res += f[v][0], ins(u, x), del.push_back(x);
  }
  while ((int)s[u].size() && (int)s[u].size() > cnt) {
    tmp.push_back(*(--s[u].end()));
    era(u, *(--s[u].end()));
  }
  f[u][0] = res + val[u];
  while ((int)s[u].size() && (int)s[u].size() > cnt - 1) {
    tmp.push_back(*(--s[u].end()));
    era(u, *(--s[u].end()));
  }
  f[u][1] = res + val[u];
  for (auto i : tmp) ins(u, i);
  for (auto i : del) era(u, i);
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read(), w = read();
    sum += w;
    G[u].push_back({v, w});
    G[v].push_back({u, w});
    deg[u]++, deg[v]++;
  }
  printf("%lld ", sum);
  for (int i = 1; i <= n; i++) {
    ver[i] = i;
    sort(G[i].begin(), G[i].end(), [](pair<int, int> &x, pair<int, int> &y) {
      return deg[x.first] > deg[y.first];
    });
  }
  sort(ver + 1, ver + n + 1, [](int x, int y) { return deg[x] < deg[y]; });
  int pos = 1;
  for (x = 1; x < n; x++) {
    while (pos <= n && deg[ver[pos]] == x) del(ver[pos]), pos++;
    long long ans = 0;
    for (int i = pos; i <= n; i++) {
      int u = ver[i];
      if (vis[u] == x) continue;
      dfs(u, 0);
      ans += f[u][0];
    }
    printf("%lld ", ans);
  }
  return 0;
}
