#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
using namespace std;
template <typename T>
void chkmax(T &x, T y) {
  x = x > y ? x : y;
}
template <typename T>
void chkmin(T &x, T y) {
  x = x > y ? y : x;
}
template <typename T>
void add(T &x, T y, T mod) {
  x = x + y > mod ? x + y - mod : x + y;
}
template <typename T>
void sub(T &x, T y, T mod) {
  x = x - y < 0 ? x - y + mod : x - y;
}
template <typename T>
void multi(T &x, T y, T mod) {
  x = 1ll * x * y % mod;
}
const int INF = (1ll << 30);
template <typename T>
void read(T &x) {
  x = 0;
  bool f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = 0;
  } while (ch > '9' || ch < '0');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  x = f ? x : -x;
}
template <typename T>
void write(T x) {
  if (x < 0) x = ~x + 1, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const int N = 3e5 + 7;
vector<pair<int, int> > G[N];
vector<long long> del, tmp;
pair<int, int> D[N];
int n, X, E, d[N], vis[N], head[N];
long long ret, ans, f[N][2];
struct HEAP {
  priority_queue<long long> a, b;
  int sz = 0;
  long long sum;
  inline void push(long long x) {
    a.push(x);
    ++sz, sum += x;
  }
  inline void erase(long long x) {
    b.push(x);
    --sz, sum -= x;
  }
  inline void pre() {
    while (a.size() && b.size() && a.top() == b.top()) a.pop(), b.pop();
  }
  inline int top() {
    pre();
    return a.top();
  }
  inline void pop() {
    pre();
    --sz, sum -= a.top();
    a.pop();
  }
  inline int size() { return sz; }
} H[N];
inline bool cmp(pair<int, int> a, pair<int, int> b) {
  return d[a.first] > d[b.first];
}
inline void addedge(int u, int v, int w) {
  G[u].push_back(make_pair(v, w));
  d[v]++;
  G[v].push_back(make_pair(u, w));
  d[u]++;
}
inline void erase(int u) {
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i].first, w = G[u][i].second;
    if (d[v] <= X) break;
    H[v].push(w);
  }
}
inline void dfs(int u, int fa) {
  vis[u] = X;
  int num = d[u] - X;
  long long res = 0;
  while (H[u].sz > num) H[u].pop();
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i].first;
    if (v == fa) continue;
    if (d[v] <= X) break;
    dfs(v, u);
  }
  tmp.clear();
  del.clear();
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i].first, w = G[u][i].second;
    if (v == fa) continue;
    if (d[v] <= X) break;
    long long x = f[v][1] + w - f[v][0];
    if (x <= 0) {
      --num;
      res += f[v][1] + w;
      continue;
    }
    res += f[v][0], H[u].push(x);
    del.push_back(x);
  }
  while (H[u].sz && H[u].sz > num) tmp.push_back(H[u].top()), H[u].pop();
  f[u][0] = res + H[u].sum;
  while (H[u].sz && H[u].sz > num - 1) tmp.push_back(H[u].top()), H[u].pop();
  f[u][1] = res + H[u].sum;
  for (int i = 0; i < tmp.size(); i++) H[u].push(tmp[i]);
  for (int i = 0; i < del.size(); i++) H[u].erase(del[i]);
}
signed main() {
  read(n);
  for (int i = 1, u, v, w; i < n; i++) {
    read(u);
    read(v);
    read(w);
    addedge(u, v, w);
    ret += w;
  }
  for (int i = 1; i <= n; i++) {
    D[i] = make_pair(d[i], i);
    sort(G[i].begin(), G[i].end(), cmp);
  }
  sort(D + 1, D + n + 1);
  printf("%lld ", ret);
  int i = 1;
  for (X = 1; X < n; X++) {
    long long ans = 0;
    while (i <= n && D[i].first == X) erase(D[i++].second);
    for (int j = i; j <= n; j++) {
      int v = D[j].second;
      if (vis[v] == X) continue;
      dfs(v, 0);
      ans += f[v][0];
    }
    printf("%lld ", ans);
  }
  return 0;
}
