#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
using namespace std;
namespace ywy {
inline int get() {
  int n = 0;
  char c;
  while ((c = getchar()) || 23333) {
    if (c >= '0' && c <= '9') break;
    if (c == '-') goto s;
  }
  n = c - '0';
  while ((c = getchar()) || 23333) {
    if (c >= '0' && c <= '9')
      n = n * 10 + c - '0';
    else
      return (n);
  }
s:
  while ((c = getchar()) || 23333) {
    if (c >= '0' && c <= '9')
      n = n * 10 - c + '0';
    else
      return (n);
  }
}
typedef struct _heap {
  priority_queue<long long> que, del;
  long long tot;
  _heap() { tot = 0; }
  inline void wh() {
    while (!que.empty() && !del.empty() && que.top() == del.top())
      que.pop(), del.pop();
  }
  inline void push(long long x) {
    if (x < 0) tot -= x;
    que.push(x);
  }
  inline void pop() {
    wh();
    if (que.empty()) return;
    if (que.top() < 0) tot += que.top();
    que.pop();
  }
  inline long long top() {
    wh();
    if (que.empty()) return (-12345678900987654ll);
    return (que.top());
  }
  inline int size() {
    wh();
    return (que.size() - del.size());
  }
  inline void erase(long long x) {
    if (x < 0) tot += x;
    del.push(x);
  }
} heap;
typedef struct _ding {
  heap qian, hou;
  inline long long balance(int d) {
    while (qian.size() > d) {
      long long cjr = qian.top();
      qian.pop();
      hou.push(-cjr);
    }
    while (qian.size() < d && hou.size()) {
      long long cjr = hou.top();
      hou.pop();
      qian.push(-cjr);
    }
    return (qian.tot);
  }
  inline void push(long long x) {
    if (x < -qian.top())
      hou.push(x);
    else
      qian.push(-x);
  }
  inline void erase(long long x) {
    if (x < -qian.top())
      hou.erase(x);
    else
      qian.erase(-x);
  }
} Duiding;
Duiding ddp[300001];
long long dp[300001][2], sig[300001];
int ints[300001], lxl[300001];
typedef struct _b {
  int dest;
  int nxt;
  int len;
} bian;
bian memchi[1000001];
int gn = 1, heads[300001];
inline void add(int s, int t, int l) {
  memchi[gn].dest = t;
  memchi[gn].len = l;
  memchi[gn].nxt = heads[s];
  heads[s] = gn;
  gn++;
}
int deep[300001], deg[300001];
vector<int> vec[300001];
typedef struct _alloc {
  bool operator()(const int &a, const int &b) {
    if (deep[a] == deep[b]) return (a < b);
    return (deep[a] > deep[b]);
  }
} alloc;
set<int, alloc> st;
inline int cmp(const int &a, const int &b) {
  if (deg[a] == deg[b]) return (a < b);
  return (deg[a] < deg[b]);
}
unsigned char bv[300001];
int fa[300001], fab[300001];
int find(int n) {
  if (ints[n] == n) return (n);
  return (ints[n] = find(ints[n]));
}
void dfs(int pt, int baba) {
  for (register int i = heads[pt]; i; i = memchi[i].nxt) {
    if (memchi[i].dest == baba) continue;
    deep[memchi[i].dest] = deep[pt] + 1;
    vec[pt].push_back(memchi[i].dest);
    fa[memchi[i].dest] = pt;
    fab[memchi[i].dest] = memchi[i].len;
    dfs(memchi[i].dest, pt);
    sig[pt] += dp[memchi[i].dest][0];
    ddp[pt].push(dp[memchi[i].dest][1] - dp[memchi[i].dest][0]);
  }
  dp[pt][1] = sig[pt] + fab[pt];
  dp[pt][0] = sig[pt] + ddp[pt].balance(1);
  sort(vec[pt].begin(), vec[pt].end(), cmp);
  reverse(vec[pt].begin(), vec[pt].end());
}
void efs(int pt, int d) {
  for (register int i = 0; i < vec[pt].size(); i++) {
    sig[pt] -= dp[vec[pt][i]][0];
    ddp[pt].erase(dp[vec[pt][i]][1] - dp[vec[pt][i]][0]);
    efs(vec[pt][i], d);
    sig[pt] += dp[vec[pt][i]][0];
    ddp[pt].push(dp[vec[pt][i]][1] - dp[vec[pt][i]][0]);
  }
  dp[pt][1] = sig[pt] + fab[pt] + ddp[pt].balance(d - 1);
  dp[pt][0] = sig[pt] + ddp[pt].balance(d);
}
void ywymain() {
  int n = get();
  long long tot = 0;
  for (register int i = 1; i < n; i++) {
    int s = get(), t = get(), l = get();
    tot += l;
    deg[s]++;
    deg[t]++;
    add(s, t, l);
    add(t, s, l);
  }
  dfs(1, 0);
  for (register int i = 1; i <= n; i++) lxl[i] = ints[i] = i;
  sort(lxl + 1, lxl + 1 + n, cmp);
  st.insert(1);
  printf("%lld ", tot);
  if (n == 1) return;
  printf("%lld ", tot - dp[1][0]);
  int ptr = 1;
  sig[0] = dp[1][0];
  bv[0] = 1;
  for (register int i = 2; i < n; i++) {
    while (ptr <= n && deg[lxl[ptr]] <= i) {
      if (bv[fa[lxl[ptr]]]) st.erase(lxl[ptr]);
      bv[lxl[ptr]] = 1;
      for (register int j = 0; j < vec[lxl[ptr]].size(); j++) {
        st.insert(vec[lxl[ptr]][j]);
      }
      int aa = find(fa[lxl[ptr]]);
      if (fa[lxl[ptr]]) vec[fa[lxl[ptr]]].pop_back();
      if (!bv[fa[lxl[ptr]]]) {
        ddp[fa[lxl[ptr]]].erase(dp[lxl[ptr]][1] - dp[lxl[ptr]][0]);
        ddp[fa[lxl[ptr]]].push(fab[lxl[ptr]]);
      }
      if (bv[fa[lxl[ptr]]]) {
        sig[find(fa[lxl[ptr]])] -= max(dp[lxl[ptr]][0], dp[lxl[ptr]][1]);
        long long old = dp[lxl[ptr]][0];
        dp[lxl[ptr]][0] = sig[lxl[ptr]] + ddp[lxl[ptr]].balance(i);
        dp[lxl[ptr]][1] = dp[lxl[ptr]][0] + fab[lxl[ptr]];
        sig[find(fa[lxl[ptr]])] += dp[lxl[ptr]][1];
      } else {
        sig[find(fa[lxl[ptr]])] -= dp[lxl[ptr]][0];
        long long old = dp[lxl[ptr]][0];
        dp[lxl[ptr]][0] = sig[lxl[ptr]] + ddp[lxl[ptr]].balance(i);
        dp[lxl[ptr]][1] = dp[lxl[ptr]][0] + fab[lxl[ptr]];
        sig[find(fa[lxl[ptr]])] += dp[lxl[ptr]][0];
      }
      ints[lxl[ptr]] = aa;
      ptr++;
    }
    for (set<int, alloc>::iterator j = st.begin(); j != st.end(); j++) {
      sig[find(fa[*j])] -= max(dp[*j][0], dp[*j][1]);
      efs(*j, i);
      sig[find(fa[*j])] += max(dp[*j][0], dp[*j][1]);
    }
    printf("%lld ", tot - sig[0]);
  }
}
}  // namespace ywy
int main() {
  ywy::ywymain();
  return (0);
}
