import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

const int INF = 100000000;
int[21][21] map;
int n;
int ans;

bool check(int x,int u){
    int count;
    for(int i=1;i<=n;i++)
	if(map[x][i] > 0 && (u&(1<<i))==0) count++;
    if(count == 1) return true;
    else return false;
}

int saiki(int pos,int u,int v,int us){

    us |= 1<<pos;

    if(v > ans) return INF;
    int res = INF;
    int count;
    bool flg = true;
    for(int i=1;i<=n;i++){
	if(map[pos][i] > 0 && (u&(1<<i)) == 0 ){
	    if(check(i,u)){
	       	u |= 1<<i;
		flg = false;
	    }
	}
    }
    for(int i=1;i<=n;i++){
	if( (u&(1<<i)) != 0 ) count++;
    }
    if(count == n-1) {
	ans = min(ans,v);
	return v;
    }
    for(int i=1;i<=n;i++){
	if( (u&(1<<i)) == 0 && map[pos][i] > 0){
	    if(flg && (us&(1<<i))!=0 ) continue;
	    res = min(res,saiki(i,u,v+map[pos][i],us) );
	}
    }
    return res;
}

void main(){

    while(true){
	n = readln().chomp().to!int;
	ans = INF;
	map = new int[21][21];
	if(n==0) break;
	for(int i=0;i<n-1;i++){
	    auto s = readln().split().to!(int[]);
	    map[s[0]][s[1]] = s[2];
	    map[s[1]][s[0]] = s[2];
	}
	writeln(saiki(1,0,0,0));
    }
}