#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

#define INF 1<<14

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;

int N, a, b, t;
int amat[22][22]={{0}};
int dist[22][22]={{0}};
int brg_count[22]={0, INF, 0};

void warshall_floyd(){
	
	for(int i=1; i<=N; ++i)
		for(int j=1; j<=N; ++j)
			dist[i][j] = (amat[i][j]>0?amat[i][j]:INF);
	
	for(int k=1; k<=N; ++k)
		for(int i=1; i<=N; ++i)
			for(int j=1; j<=N; ++j)
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
	
	return;
}

int solve(){
	
	warshall_floyd();
	
	int sum = 0;
	
	for(int i=1; i<=N; ++i){
		for(int j=i; j<=N; ++j){
			
			if( amat[i][j] && brg_count[i]>1 && brg_count[j]>1 )
				sum += 2*amat[i][j];
		}
	}
	
	int res = sum;
	
	for(int k=2; k<=N; ++k){
		if( brg_count[k] > 1 )
			res = min(res, sum - dist[1][k]);
	}
	
	return res<sum ? res : 0;
}	

int main(){
		
	while(cin >> N, N){
		
		CLR(amat);
		CLR(dist);
		CLR(brg_count);
		brg_count[1] = INF;
		
		for(int i=0; i < N-1; ++i){
			cin >> a >> b >> t;
			amat[a][b] = amat[b][a] = t;
			brg_count[a]++;
			brg_count[b]++;
		}
		
		cout << solve() << endl;
	}
	
	return 0;
}