#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;

int maxn;
vector<int> to[21];
int cost[21][21];
int tree[21];//その木の種類を示す //0:tree,1:leaf,2:last
bool isgo[21];


int dfs(int t,int c)
{
	int sum = 0;
	isgo[t] = true;
	bool go = false;
	for(int i=0;i<to[t].size();++i){
		int next = to[t][i];
		if(isgo[next])
			continue;
		else{
			go = true;
			int num = dfs(next,cost[t][next]);
			if(num == 0){
				tree[next] = 1;
				tree[t] = 2;
			}
			sum += num;
		}
	}
	if(go)
		return sum+c;
	else//どこにも行くところがなかった
		return 0;
}

int maxcost;

void check(int t,int sumc)//2回目のＤＦＳ・・・ムダー
{
	bool b=false;
	isgo[t] = true;
	for(int i=0;i<to[t].size();++i){
		int next = to[t][i];
		if(tree[next] == 1 || isgo[next])
			continue;
		else{
			b = true;
			check(next,cost[t][next]+sumc);
		}
	}
	if(!b){//行き先がない
		if(maxcost < sumc)
			maxcost = sumc;
	}
}

int main(void)
{
	while(1){
		cin >> maxn;
		if(maxn == 0)
			return 0;
		memset(isgo,false,sizeof(isgo));
		memset(tree,0,sizeof(tree));
		for(int i=0;i<21;++i)
		{
			to[i].clear();
		}
		memset(cost,0,sizeof(cost));
		for(int i=0;i<maxn-1;++i){
			int a,b,c;
			cin >> a >> b >> c;
			to[a].push_back(b);
			to[b].push_back(a);
			cost[a][b] = c;
			cost[b][a] = c;
		}
		int sum = dfs(1,0)*2;
		memset(isgo,false,sizeof(isgo));
		maxcost = 0;
		check(1,0);
		cout << sum - maxcost << endl;
	}
	
	return 0;
}