#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
using namespace std;
template <typename Tp>
inline void read(Tp &x) {
  static char c;
  static bool neg;
  x = 0, c = getchar(), neg = false;
  for (; !isdigit(c); c = getchar()) {
    if (c == '-') {
      neg = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (neg) {
    x = -x;
  }
}
const int N = 250000 + 5;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int n;
int deg[N];
pair<int, int> D[N];
vector<pair<int, long long>> G[N];
inline void addE(int u, int v, long long w) {
  G[u].emplace_back(v, w);
  G[v].emplace_back(u, w);
  ++deg[u], ++deg[v];
}
inline bool comp(const pair<int, int> &x, const pair<int, int> &y) {
  return deg[x.first] > deg[y.first];
}
struct Heap {
  multiset<long long> set;
  long long sum;
  inline Heap() { sum = 0; }
  inline void push(const long long &x) {
    sum += x;
    set.emplace(x);
  }
  inline void erase(const long long &x) {
    sum -= x;
    set.erase(set.find(x));
  }
  inline long long pop() {
    auto ptr = prev(set.end());
    long long res = *ptr;
    sum -= res;
    set.erase(ptr);
    return res;
  }
  inline void shrink(int lim) {
    lim = std::max(lim, 0);
    int need = (int)set.size() - lim;
    while (need > 0) {
      pop();
      --need;
    }
  }
  inline void transfer(int lim, vector<long long> &vec) {
    lim = std::max(lim, 0);
    int need = (int)set.size() - lim;
    while (need > 0) {
      vec.emplace_back(pop());
      --need;
    }
  }
};
Heap heap[N];
int x;
int vis[N];
long long dp[N][2];
void remove(int u) {
  for (const auto &p : G[u]) {
    int v = p.first;
    long long w = p.second;
    if (deg[v] > x) {
      heap[v].push(w);
    }
  }
}
void dfs(int u, int fa) {
  vis[u] = x;
  int lim = deg[u] - x;
  heap[u].shrink(lim);
  for (const auto &p : G[u]) {
    int v = p.first;
    if (v != fa) {
      if (deg[v] <= x) {
        break;
      }
      dfs(v, u);
    }
  }
  vector<long long> vec, del;
  long long res = 0;
  for (const auto &p : G[u]) {
    int v = p.first;
    long long w = p.second;
    if (v != fa) {
      if (deg[v] <= x) {
        break;
      }
      long long t = dp[v][1] + w - dp[v][0];
      if (t <= 0) {
        --lim;
        res += dp[v][1] + w;
      } else {
        res += dp[v][0];
        heap[u].push(t);
        del.emplace_back(t);
      }
    }
  }
  heap[u].transfer(lim, vec);
  dp[u][0] = res + heap[u].sum;
  heap[u].transfer(lim - 1, vec);
  dp[u][1] = res + heap[u].sum;
  for (const auto &v : vec) {
    heap[u].push(v);
  }
  for (const auto &v : del) {
    heap[u].erase(v);
  }
}
int main() {
  read(n);
  long long ans = 0;
  for (int i = 1, u, v, w; i < n; ++i) {
    read(u), read(v), read(w);
    addE(u, v, (long long)w);
    ans += w;
  }
  printf("%lld ", ans);
  for (int i = 1; i <= n; ++i) {
    D[i] = (pair<int, int>){deg[i], i};
    sort(G[i].begin(), G[i].end(), comp);
  }
  sort(D + 1, D + n + 1);
  int pos = 1;
  for (x = 1; x < n; ++x) {
    while (pos <= n && D[pos].first == x) {
      remove(D[pos].second);
      ++pos;
    }
    ans = 0;
    for (int i = pos, v; i <= n; ++i) {
      v = D[i].second;
      if (vis[v] != x) {
        dfs(v, 0);
        ans += dp[v][0];
      }
    }
    printf("%lld ", ans);
  }
}
