#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 5007;
const int inf = 1e16;
int n, dp[N][N][2];
vector<pair<int, int>> adj[N];
void dfs (int u, int p){
dp[u][1][0] = dp[u][1][1] = 0;
for (pair<int, int> pr : adj[u]){
int v = pr.first, w = pr.second;
if (v != p)
dfs(v, u);
}
for (pair<int, int> pr : adj[u]){
int v = pr.first, w = pr.second;
if (v != p){
for (int i = n; i >= 2; --i)
for (int j = 1; j < i; ++j){
dp[u][i][0] = min(dp[u][i][0], dp[u][i - j][0] + (dp[v][j][0] + w) * 2);
dp[u][i][1] = min(dp[u][i][1], dp[u][i - j][1] + (dp[v][j][0] + w) * 2);
dp[u][i][1] = min(dp[u][i][1], dp[u][i - j][0] + dp[v][j][1] + w);
}
}
}
}
int32_t main (){
ios::sync_with_stdio(false); cin.tie(nullptr);
freopen("migration.inp", "r", stdin);
freopen("migration.out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j){
dp[i][j][0] = inf;
dp[i][j][1] = inf;
}
for (int i = 1; i < n; ++i){
int u, v, w; cin >> u >> v >> w;
adj[u].push_back({v, w});
adj[v].push_back({u, w});
}
dfs(1, 0);
for (int i = 1; i <= n; ++i)
cout << dp[1][i][1] << "\n";
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGludCBsb25nIGxvbmcKCmNvbnN0IGludCBOID0gNTAwNzsKY29uc3QgaW50IGluZiA9IDFlMTY7CgppbnQgbiwgZHBbTl1bTl1bMl07CnZlY3RvcjxwYWlyPGludCwgaW50Pj4gYWRqW05dOwoKdm9pZCBkZnMgKGludCB1LCBpbnQgcCl7CiAgICBkcFt1XVsxXVswXSA9IGRwW3VdWzFdWzFdID0gMDsKICAgIGZvciAocGFpcjxpbnQsIGludD4gcHIgOiBhZGpbdV0pewogICAgICAgIGludCB2ID0gcHIuZmlyc3QsIHcgPSBwci5zZWNvbmQ7CiAgICAgICAgaWYgKHYgIT0gcCkKICAgICAgICAgICAgZGZzKHYsIHUpOwogICAgfQogICAgZm9yIChwYWlyPGludCwgaW50PiBwciA6IGFkalt1XSl7CiAgICAgICAgaW50IHYgPSBwci5maXJzdCwgdyA9IHByLnNlY29uZDsKICAgICAgICBpZiAodiAhPSBwKXsKICAgICAgICAgICAgZm9yIChpbnQgaSA9IG47IGkgPj0gMjsgLS1pKQogICAgICAgICAgICAgICAgZm9yIChpbnQgaiA9IDE7IGogPCBpOyArK2opewogICAgICAgICAgICAgICAgICAgIGRwW3VdW2ldWzBdID0gbWluKGRwW3VdW2ldWzBdLCBkcFt1XVtpIC0gal1bMF0gKyAoZHBbdl1bal1bMF0gKyB3KSAqIDIpOwogICAgICAgICAgICAgICAgICAgIGRwW3VdW2ldWzFdID0gbWluKGRwW3VdW2ldWzFdLCBkcFt1XVtpIC0gal1bMV0gKyAoZHBbdl1bal1bMF0gKyB3KSAqIDIpOwogICAgICAgICAgICAgICAgICAgIGRwW3VdW2ldWzFdID0gbWluKGRwW3VdW2ldWzFdLCBkcFt1XVtpIC0gal1bMF0gKyBkcFt2XVtqXVsxXSArIHcpOwogICAgICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfQoKaW50MzJfdCBtYWluICgpewogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOyBjaW4udGllKG51bGxwdHIpOwogICAgZnJlb3BlbigibWlncmF0aW9uLmlucCIsICJyIiwgc3RkaW4pOwogICAgZnJlb3BlbigibWlncmF0aW9uLm91dCIsICJ3Iiwgc3Rkb3V0KTsKICAgIGNpbiA+PiBuOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgKytpKQogICAgICAgIGZvciAoaW50IGogPSAxOyBqIDw9IG47ICsrail7CiAgICAgICAgICAgIGRwW2ldW2pdWzBdID0gaW5mOwogICAgICAgICAgICBkcFtpXVtqXVsxXSA9IGluZjsKICAgICAgICB9CiAgICBmb3IgKGludCBpID0gMTsgaSA8IG47ICsraSl7CiAgICAgICAgaW50IHUsIHYsIHc7IGNpbiA+PiB1ID4+IHYgPj4gdzsKICAgICAgICBhZGpbdV0ucHVzaF9iYWNrKHt2LCB3fSk7CiAgICAgICAgYWRqW3ZdLnB1c2hfYmFjayh7dSwgd30pOwogICAgfQogICAgZGZzKDEsIDApOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgKytpKQogICAgICAgIGNvdXQgPDwgZHBbMV1baV1bMV0gPDwgIlxuIjsKfQo=