#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int maxn=2e5+9,S=420;
i64 dp[maxn][2];
int deg[maxn],mark[maxn];
vector<pair<int,i64>> adj[maxn];
inline void DFSdp(int u,int pu,int k)
{
i64 sum=0;
vector<pair<i64,i64>> hmm;
for(auto& [v,w]:adj[u])
{
if(v!=pu)
{
DFSdp(v,u,k);
hmm.push_back({dp[v][0],dp[v][1]+w});
sum+=dp[v][1]+w;
}
}
sort(hmm.begin(),hmm.end(),[&](pair<i64,i64> x,pair<i64,i64> y){
return x.first-x.second<y.first-y.second;
});
dp[u][0]=dp[u][1]=sum;
for(int ch=0,i=0;i<hmm.size();++i)
{
if(hmm[i].first<hmm[i].second) sum+=hmm[i].first-hmm[i].second,++ch;
if(ch<k) dp[u][0]=sum;
if(ch<=k) dp[u][1]=sum;
}
}
vector<int> NodeList;
vector<pair<int,i64>> bdj[maxn];
struct Raven
{
multiset<i64> Rachel,Roth;
i64 sumin=0,sumall=0;
inline void Calibrate(int k)
{
while(!Rachel.empty() and (Rachel.size()>k or *Rachel.rbegin()>=0))
{
auto it=prev(Rachel.end());
Roth.insert(*it); sumin-=*it;
Rachel.erase(it);
}
while(!Roth.empty() and Rachel.size()<k and *Roth.begin()<0)
{
auto it=Roth.begin();
Rachel.insert(*it); sumin+=*it;
Roth.erase(it);
}
}
inline void Add(i64 x)
{
if(!Rachel.empty() and x<=*Rachel.rbegin())
{
Rachel.insert(x);
sumin+=x;
}
else Roth.insert(x);
sumall+=x;
}
inline void Remove(i64 x)
{
auto it=Rachel.find(x);
if(it==Rachel.end()) Roth.erase(Roth.find(x));
else Rachel.erase(it),sumin-=x;
sumall-=x;
}
inline void PrintDebug()
{
if(Rachel.empty()) cout<<"x ";
else {for(auto x:Rachel) cout<<x<<" ";}
cout<<"|";
if(Roth.empty()) cout<<" x";
else {for(auto x:Roth) cout<<" "<<x;}
cout<<" | "<<sumin<<"/"<<sumall<<"\n";
}
};
Raven Yioo[maxn];
int maxdeg[maxn];
inline void DFSrg(int u,int pu)
{
if(mark[u]) NodeList.push_back(u);
for(auto& [v,w]:adj[u])
{
if(v!=pu)
{
DFSrg(v,u); maxdeg[u]=max(maxdeg[u],maxdeg[v]);
if(mark[u]==1)
{
if(mark[v]==1) bdj[u].push_back({v,w});
else Yioo[u].Add(-w);
}
}
else if(mark[u]==1 and mark[v]==0) Yioo[u].Add(-w);
}
maxdeg[u]=max(maxdeg[u],deg[u]);
}
inline void DFSdp2(int u,int pu,int k)
{
//if(maxdeg[u]<k) return void(dp[u][0]=dp[u][1]=0);
i64 sum=-Yioo[u].sumall; mark[u]=0;
for(auto& [v,w]:bdj[u])
{
if(v!=pu)
{
DFSdp2(v,u,k);
Yioo[u].Add(dp[v][0]-dp[v][1]-w);
sum+=dp[v][1]+w;
}
}
Yioo[u].Calibrate(k); dp[u][0]=dp[u][1]=sum+Yioo[u].sumin;
if(Yioo[u].Rachel.size()==k) dp[u][0]-=*Yioo[u].Rachel.rbegin();
}
vector<i64> minimum_closure_costs(int N,vector<int> U,vector<int> V,vector<int> W)
{
vector<i64> res(N,0);
for(int i=1;i<N;++i)
{
res[0]+=W[i-1],++deg[U[i-1]],++deg[V[i-1]];
adj[U[i-1]].push_back({V[i-1],W[i-1]});
adj[V[i-1]].push_back({U[i-1],W[i-1]});
}
for(int i=0;i<N;++i)
if(deg[i]>S) mark[i]=1;
DFSrg(0,-1);
for(int k=1;k<=min(S,maxdeg[0]);++k)
{
DFSdp(0,-1,k);
res[k]=dp[0][1];
}
for(int k=S+1;k<maxdeg[0];++k)
{
for(int& u:NodeList)
{
if(mark[u]==1)// and maxdeg[u]>=k)
{
DFSdp2(u,-1,k);
res[k]+=dp[u][1];
}
}
for(int& u:NodeList)
{
for(auto& [v,w]:bdj[u])
Yioo[u].Remove(dp[v][0]-dp[v][1]-w);
mark[u]=1;
}
}
return res;
}
#ifdef Graven
int n; vector<int> u,v,w;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>n; u.resize(n); v.resize(n); w.resize(n);
for(int i=1;i<n;++i) cin>>u[i-1]>>v[i-1]>>w[i-1];
vector<i64> res=minimum_closure_costs(n,u,v,w);
for(int i=0;i<n;++i) cout<<res[i]<<" ";
}
#endif
/*
5
0 1 1
0 2 4
0 3 3
2 4 2
-> 10 5 1 0 0
4
0 1 5
2 0 10
0 3 5
-> 20 10 5 0
10
0 1 1
0 2 1
0 3 1
1 4 1
1 5 1
2 6 1
2 7 1
3 8 1
3 9 1
-> 9 6 3 0 0 0 0 0 0 0
10
0 1 1
0 2 1
2 4 1
2 3 1
3 5 1
3 6 1
5 7 1
2 8 1
2 9 1
-> 9 5 3 2 1 0 0 0 0 0
*/