#include <bits/stdc++.h>
using namespace std;
const int MX = 250005;
const long long inf = 1e12;
struct Treap {
  Treap *left, *right;
  int val, key, size;
  long long sum;
  Treap(int val = 0)
      : val(val), key(rand()), size(1), left(0), right(0), sum(val) {}
} * t[MX];
inline int nodeSize(Treap* T) { return T ? T->size : 0; }
inline long long nodeSum(Treap* T) { return T ? T->sum : 0; }
inline void update(Treap* T) {
  if (T) {
    T->size = 1 + nodeSize(T->left) + nodeSize(T->right);
    T->sum = T->val + nodeSum(T->left) + nodeSum(T->right);
  }
}
void merge(Treap*& T, Treap* T1, Treap* T2) {
  if (!T1)
    T = T2;
  else if (!T2)
    T = T1;
  else if (T1->key > T2->key)
    merge(T1->right, T1->right, T2), T = T1;
  else
    merge(T2->left, T1, T2->left), T = T2;
  update(T);
}
void split(Treap* T, int x, Treap*& T1, Treap*& T2) {
  if (!T) return void(T1 = T2 = NULL);
  if (x < T->val)
    split(T->left, x, T1, T->left), T2 = T;
  else
    split(T->right, x, T->right, T2), T1 = T;
  update(T);
}
void insert(Treap*& T, Treap* x) {
  if (!T)
    T = x;
  else if (x->key > T->key)
    split(T, x->val, x->left, x->right), T = x;
  else
    insert(x->val < T->val ? T->left : T->right, x);
  update(T);
}
void insert(Treap*& T, int x) { insert(T, new Treap(x)); }
void erase(Treap*& T, int x) {
  if (!T) return;
  if (T->val == x)
    merge(T, T->left, T->right);
  else
    erase(x < T->val ? T->left : T->right, x);
  update(T);
}
long long kth(Treap* T, int i) {
  if (!T || i < 1) return 0;
  int curr = nodeSize(T->left);
  if (i == curr + 1) return nodeSum(T->left) + T->val;
  if (i < curr + 1) return kth(T->left, i);
  return kth(T->right, i - curr - 1) + nodeSum(T->left) + T->val;
}
int n, a, b, c, x, vis[MX], p[MX];
long long res[MX], mem[2][MX];
vector<int> deg[MX], in;
vector<pair<int, int> > adj[MX], gra[MX];
bitset<MX> bs;
long long dp(int u, int p, int f) {
  long long& res = mem[f][u];
  if (res != -1) return res;
  res = inf;
  vis[u] = x;
  long long s = 0;
  vector<long long> aux;
  for (pair<int, int>& v : gra[u])
    if (v.first != p) {
      s += dp(v.first, u, 0);
      aux.push_back(dp(v.first, u, 1) - dp(v.first, u, 0) + v.second);
    }
  sort(aux.begin(), aux.end());
  for (int k = 0; k <= aux.size(); k++) {
    int d = (int)adj[u].size() - x - f;
    if (d - k <= nodeSize(t[u])) res = min(res, s + kth(t[u], d - k));
    if (k < aux.size()) s += aux[k];
  }
  return res;
}
int main() {
  memset(mem, -1, sizeof(mem));
  srand(time(0));
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d %d %d", &a, &b, &c);
    adj[a].emplace_back(b, c);
    adj[b].emplace_back(a, c);
  }
  for (int i = 1; i <= n; i++) deg[adj[i].size()].push_back(i);
  for (x = n - 1; x >= 0; x--) {
    for (int u : in)
      if (mem[0][u] == -1) res[x] += dp(u, -1, 0);
    for (int u : in) mem[0][u] = mem[1][u] = -1;
    for (int u : deg[x]) {
      bs[u] = 1;
      in.push_back(u);
      for (pair<int, int>& v : adj[u])
        if (bs[v.first]) {
          erase(t[v.first], v.second);
          gra[u].emplace_back(v.first, v.second);
          gra[v.first].emplace_back(u, v.second);
        } else {
          insert(t[u], v.second);
        }
    }
  }
  for (int i = 0; i < n; i++) printf("%I64d ", res[i]);
  printf("\n");
  return 0;
}
