#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  char cu = getchar();
  x = 0;
  bool fla = 0;
  while (!isdigit(cu)) {
    if (cu == '-') fla = 1;
    cu = getchar();
  }
  while (isdigit(cu)) x = x * 10 + cu - '0', cu = getchar();
  if (fla) x = -x;
}
template <typename T>
inline void printe(const T x) {
  if (x >= 10) printe(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void print(const T x) {
  if (x < 0)
    putchar('-'), printe(-x);
  else
    printe(x);
}
template <typename T>
inline T min(const T a, const T b) {
  return a < b ? a : b;
}
template <typename T>
inline T max(const T a, const T b) {
  return a > b ? a : b;
}
template <typename T>
inline T gcd(const T a, const T b) {
  if (!b) return a;
  return gcd(b, a % b);
}
template <typename T>
inline void maxd(T &a, const T b) {
  a = a > b ? a : b;
}
template <typename T>
inline T abs(const T a) {
  return a > 0 ? a : -a;
}
const int maxn = 250001, maxm = 500001;
int n, head[maxn], nxt[maxm], tow[maxm], vau[maxm], tmp, d[maxn];
inline void addb(const int u, const int v, const int w) {
  tmp++;
  nxt[tmp] = head[u];
  head[u] = tmp;
  tow[tmp] = v;
  vau[tmp] = w;
}
std::vector<int> T[maxn];
int fa[maxn], nex[maxn + 1], las;
void ffa(const int u) {
  for (register int i = head[u]; i; i = nxt[i]) {
    const int v = tow[i];
    if (v != fa[u]) fa[v] = u, ffa(v);
  }
}
bool vis[maxn];
struct SET {
  std::multiset<int, std::greater<int> > main;
  std::vector<int> erased, added;
  long long lj;
  int tot;
  void insert(const int x) { main.insert(x), lj += x, tot++; }
  void resize(const int x) {
    while (tot > x) {
      tot--, lj -= *main.begin();
      main.erase(main.begin());
    }
  }
  void RESIZE(const int x) {
    while (tot > x) {
      tot--, lj -= *main.begin(), erased.push_back(*main.begin());
      main.erase(main.begin());
    }
  }
  void INSERT(const int x) {
    main.insert(x), lj += x, tot++;
    added.push_back(x);
  }
  void BACK() {
    for (std::vector<int>::iterator Pos = erased.begin(); Pos != erased.end();
         Pos++)
      main.insert(*Pos), tot++, lj += *Pos;
    erased.clear();
    for (std::vector<int>::iterator Pos = added.begin(); Pos != added.end();
         Pos++)
      main.erase(main.find(*Pos)), tot--, lj -= *Pos;
    added.clear();
  }
} s[maxn];
long long f[maxn][2];
int G;
void dfs(const int u) {
  int ned = d[u] - G;
  s[u].resize(ned);
  long long tot = 0;
  int *lc = &head[u];
  for (register int i = head[u]; i; i = nxt[i]) {
    const int v = tow[i];
    if (vis[v]) {
      (*lc) = nxt[i];
      continue;
    } else
      lc = &nxt[i];
    if (v != fa[u]) {
      dfs(v);
      if (f[v][1] + vau[i] <= f[v][0])
        ned--, tot += f[v][1] + vau[i];
      else {
        tot += f[v][0];
        s[u].INSERT(f[v][1] + vau[i] - f[v][0]);
      }
    }
  }
  s[u].RESIZE(max(ned, 0));
  f[u][0] = s[u].lj + tot;
  ned--;
  s[u].RESIZE(max(ned, 0));
  f[u][1] = s[u].lj + tot;
  s[u].BACK();
}
int main() {
  read(n);
  for (register int i = 1; i < n; i++) {
    int u, v, w;
    read(u), read(v), read(w);
    addb(u, v, w), addb(v, u, w), d[u]++, d[v]++;
  }
  for (register int i = 1; i <= n; i++) T[d[i]].push_back(i);
  for (register int i = n; i >= 1; i--) {
    nex[i] = las;
    if (!T[i].empty()) las = i;
  }
  vis[0] = 1;
  ffa(1);
  for (register int i = 1; i <= n; i++) {
    G = i - 1;
    long long ans = 0;
    for (register int p = i; p; p = nex[p]) {
      for (std::vector<int>::iterator Pos = T[p].begin(); Pos != T[p].end();
           Pos++)
        if (vis[fa[*Pos]]) {
          dfs(*Pos);
          ans += f[*Pos][0];
        }
    }
    print(ans), putchar('\n');
    for (std::vector<int>::iterator Pos = T[i].begin(); Pos != T[i].end();
         Pos++) {
      const int u = *Pos;
      vis[u] = 1;
      for (register int j = head[u]; j; j = nxt[j]) {
        const int v = tow[j];
        if (!vis[v]) s[v].insert(vau[j]);
      }
    }
  }
  return 0;
}
