#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
const int N = 250010;
int n, uD, nxt[N], d[N];
long long ans = 0, sum[N], f[2][N];
vector<pair<int, int> > e[N];
vector<int> deg[N];
bool vis[N];
struct Heap {
  priority_queue<long long> In, Out;
  inline void push(long long x) { In.push(x); }
  inline void erase(long long x) { Out.push(x); }
  long long top() {
    for (; !Out.empty() && In.top() == Out.top(); In.pop(), Out.pop())
      ;
    return In.top();
  }
  void pop() { top(), In.pop(); }
  long long size() { return In.size() - Out.size(); }
};
Heap h[N];
inline int Max(const int &x, const int &y) { return x > y ? x : y; }
inline bool cmp(const pair<int, int> &x, const pair<int, int> &y) {
  return d[x.first] > d[y.first];
}
void solve(int x) {
  for (auto v : e[x]) {
    if (d[v.first] <= uD) break;
    h[v.first].push(v.second), sum[v.first] += v.second;
  }
}
void pop(int u, int num) {
  for (; h[u].size() > num;) sum[u] -= h[u].top(), h[u].pop();
}
void Pop(int u, int num, vector<long long> &x) {
  for (; h[u].size() > num;)
    sum[u] -= h[u].top(), x.push_back(h[u].top()), h[u].pop();
}
void dfs(int u) {
  vis[u] = 1;
  int num = d[u] - uD;
  pop(u, num);
  long long ss = 0;
  vector<long long> del, add;
  for (auto v : e[u])
    if (!vis[v.first]) {
      if (d[v.first] <= uD) break;
      dfs(v.first);
      if (f[1][v.first] + v.second <= f[0][v.first])
        --num, ss += f[1][v.first] + v.second;
      else {
        ss += f[0][v.first];
        long long dt = f[1][v.first] + v.second - f[0][v.first];
        del.push_back(dt), sum[u] += dt, h[u].push(dt);
      }
    }
  Pop(u, Max(0, num), add), f[0][u] = ss + sum[u];
  Pop(u, Max(0, num - 1), add), f[1][u] = ss + sum[u];
  for (auto x : add) h[u].push(x), sum[u] += x;
  for (auto x : del) h[u].erase(x), sum[u] -= x;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y, z; i < n; i++) {
    scanf("%d%d%d", &x, &y, &z), ans += z, ++d[x], ++d[y];
    e[x].emplace_back(y, z), e[y].emplace_back(x, z);
  }
  for (int i = 1; i <= n; i++)
    deg[d[i]].push_back(i), sort(e[i].begin(), e[i].end(), cmp);
  nxt[n] = n + 1;
  for (int i = n - 1; i; i--) {
    if (deg[i + 1].size())
      nxt[i] = i + 1;
    else
      nxt[i] = nxt[i + 1];
  }
  printf("%I64d", ans);
  for (int i = 1; i < n; i++) {
    ans = 0, uD = i;
    for (auto x : deg[i]) solve(x);
    for (int j = nxt[i]; j <= n; j = nxt[j])
      for (auto x : deg[j])
        if (!vis[x]) dfs(x), ans += f[0][x];
    for (int j = nxt[i]; j <= n; j = nxt[j])
      for (auto x : deg[j]) vis[x] = 0;
    printf(" %I64d", ans);
  }
  return 0;
}
