#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int N;
int d[20];
vector<pii> g[20];

void dfs(int u, int prev) {
	REP(i, g[u].size()) if (g[u][i].fi != prev) {
		d[g[u][i].fi] = d[u] + g[u][i].se;
		dfs(g[u][i].fi, u);
	}
}

int main() {
	while (cin >> N, N) {
		REP(i, N) g[i].clear();
		
		int sum = 0;
		
		REP(i, N - 1) {
			int a, b, t;
			scanf("%d %d %d", &a, &b, &t);
			a--; b--;
			g[a].push_back(pii(b, t));
			g[b].push_back(pii(a, t));
			sum += t * 2;
		}
		
		d[0] = 0;
		dfs(0, -1);
		
		int ma = -1;
		FOR(i, 1, N) if (g[i].size() == 1) {
			sum -= g[i][0].se * 2;
			chmax(ma, d[g[i][0].fi]);
		}
		
		cout << sum - ma << endl;
		
	}
	return 0;
}