#include <bits/stdc++.h>
using namespace std;
int n;
struct Heap {
  long long sum;
  int siz;
  priority_queue<long long> q, del;
  int size() { return siz; }
  void work() {
    while (del.size() && q.top() == del.top()) {
      q.pop();
      del.pop();
    }
    return;
  }
  void push(long long x) {
    q.push(x);
    sum += x;
    siz++;
    return;
  }
  void erase(long long x) {
    del.push(x);
    sum -= x;
    siz--;
    return;
  }
  long long top() {
    work();
    return q.top();
  }
  void pop() {
    work();
    sum -= q.top();
    q.pop();
    siz--;
    return;
  }
} S[250010];
int deg[250010];
bool cmp(pair<int, int> a, pair<int, int> b) {
  return deg[a.first] > deg[b.first];
}
vector<pair<int, int> > e[250010];
long long dp[250010][2];
int vis[250010];
void dfs(int u, int lim) {
  vis[u] = lim;
  int num = deg[u] - lim;
  while (S[u].size() > num) S[u].pop();
  long long res = 0;
  vector<long long> vec1, vec2;
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i].first;
    int c = e[u][i].second;
    if (vis[v] == lim) continue;
    if (deg[v] <= lim) break;
    dfs(v, lim);
    res += dp[v][0];
    long long val = dp[v][1] + c - dp[v][0];
    if (val < 0) {
      res += val;
      num--;
    } else {
      vec1.push_back(val);
      S[u].push(val);
    }
  }
  while (S[u].size() > max(num, 0)) {
    vec2.push_back(S[u].top());
    S[u].pop();
  }
  dp[u][0] = res + S[u].sum;
  while (S[u].size() > max(num - 1, 0)) {
    vec2.push_back(S[u].top());
    S[u].pop();
  }
  dp[u][1] = res + S[u].sum;
  for (int i = 0; i < vec2.size(); i++) S[u].push(vec2[i]);
  for (int i = 0; i < vec1.size(); i++) S[u].erase(vec1[i]);
  return;
}
void work(int u) {
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i].first;
    int c = e[u][i].second;
    S[v].push(c);
  }
  return;
}
pair<int, int> id[250010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v, c;
    scanf("%d %d %d", &u, &v, &c);
    e[u].push_back(make_pair(v, c));
    e[v].push_back(make_pair(u, c));
    deg[u]++;
    deg[v]++;
  }
  for (int i = 1; i <= n; i++) {
    sort(e[i].begin(), e[i].end(), cmp);
    id[i] = make_pair(deg[i], i);
  }
  sort(id + 1, id + n + 1);
  memset(vis, -1, sizeof(vis));
  int now = 1;
  for (int i = 0; i < n; i++) {
    while (now <= n && id[now].first <= i) {
      work(id[now].second);
      now++;
    }
    long long ans = 0;
    for (int j = now; j <= n; j++) {
      int u = id[j].second;
      if (vis[u] == i) continue;
      dfs(u, i);
      ans += dp[u][0];
    }
    printf("%lld ", ans);
  }
  printf("\n");
  return 0;
}
