#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + ch - '0', ch = getchar();
  return s * f;
}
const int N = 250005;
vector<pair<int, int> > e[N];
int deg[N];
inline void adde(int u, int v, int w) {
  e[u].push_back(make_pair(v, w));
  ++deg[u];
  e[v].push_back(make_pair(u, w));
  ++deg[v];
}
int id[N];
inline bool cmp(int a, int b) { return deg[a] < deg[b]; }
inline bool cmp2(pair<int, int> a, pair<int, int> b) {
  return deg[a.first] > deg[b.first];
}
int n;
struct Heap {
  priority_queue<long long> q, del;
  int sz;
  long long sum;
  inline void init() {
    while (!q.empty()) q.pop();
    while (!del.empty()) del.pop();
    sz = sum = 0;
  }
  inline void push(long long x) {
    ++sz;
    sum += x;
    q.push(x);
  }
  inline void erase(long long x) {
    --sz;
    sum -= x;
    del.push(x);
  }
  inline void update() {
    while (!q.empty() && !del.empty() && q.top() == del.top())
      q.pop(), del.pop();
  }
  inline long long top() {
    update();
    return q.top();
  }
  inline void pop() {
    --sz;
    sum -= top();
    q.pop();
  }
  inline bool empty() { return sz <= 0; }
} q[N];
int cur;
inline void del(int u) {
  for (pair<int, int> i : e[u]) {
    int v = i.first, len = i.second;
    if (deg[v] <= cur) break;
    q[v].push(len);
  }
}
int vis[N];
long long f[N][2];
long long stac[N], top;
inline void undo(int u) {
  while (top) q[u].push(stac[top--]);
}
void dfs(int u, int fa) {
  vis[u] = cur;
  f[u][0] = f[u][1] = 0;
  for (pair<int, int> i : e[u]) {
    int v = i.first;
    if (v == fa) continue;
    if (deg[v] <= cur) break;
    dfs(v, u);
  }
  top = 0;
  int cnt = deg[u] - cur;
  long long sum = 0;
  while (!q[u].empty() && q[u].sz > cnt) q[u].pop();
  for (pair<int, int> i : e[u]) {
    int v = i.first, len = i.second;
    if (v == fa) continue;
    if (deg[v] <= cur) break;
    if (f[v][1] + len <= f[v][0]) {
      --cnt;
      sum += f[v][1] + len;
    } else {
      sum += f[v][0];
      q[u].push(f[v][1] + len - f[v][0]);
      while (!q[u].empty() && q[u].sz > cnt)
        stac[++top] = q[u].top(), q[u].pop();
    }
  }
  while (!q[u].empty() && q[u].sz > cnt) stac[++top] = q[u].top(), q[u].pop();
  f[u][0] = sum + q[u].sum;
  while (!q[u].empty() && q[u].sz > cnt - 1)
    stac[++top] = q[u].top(), q[u].pop();
  f[u][1] = sum + q[u].sum;
  undo(u);
  for (pair<int, int> i : e[u]) {
    int v = i.first, len = i.second;
    if (v == fa) continue;
    if (deg[v] <= cur) break;
    if (f[v][1] + len > f[v][0]) q[u].erase(f[v][1] + len - f[v][0]);
  }
}
int main() {
  n = read();
  long long sum = 0;
  for (int i = 1, u, v, w; i < n; ++i) {
    u = read();
    v = read();
    w = read();
    adde(u, v, w);
    sum += w;
  }
  for (int i = 1; i <= n; ++i) id[i] = i, sort(e[i].begin(), e[i].end(), cmp2);
  sort(id + 1, id + 1 + n, cmp);
  int flag = 1;
  printf("%lld ", sum);
  for (cur = 1; cur < n; ++cur) {
    while (flag <= n && deg[id[flag]] <= cur) del(id[flag]), ++flag;
    long long ans = 0;
    for (int i = flag, u; i <= n; ++i) {
      u = id[i];
      if (vis[u] != cur) {
        dfs(u, 0);
        ans += f[u][0];
      }
    }
    printf("%lld ", ans);
  }
  return 0;
}
