#include<queue>
#include<cstdio>

#define	mp			make_pair
#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

typedef	pair<int,int>	pii;

const int INF=1<<29;

int main(){
	for(int n;scanf("%d",&n),n;){
		int adj[20][20],deg[20]={};
		rep(u,n)rep(v,n)	adj[u][v]=INF;
		rep(i,n-1){
			int a,b,t;	scanf("%d%d%d",&a,&b,&t);
			a--,b--;
			adj[a][b]=adj[b][a]=t;
			deg[a]++,deg[b]++;
		}

		for(int u=1;u<n;u++)if(deg[u]==1){	// delete leaves
			rep(v,n)	adj[u][v]=adj[v][u]=INF;
		}

		int lmax=0;
		bool visited[20]={};
		queue<pii> qu;	qu.push(mp(0,0));
		while(!qu.empty()){
			pii a=qu.front();	qu.pop();
			int u=a.first,len=a.second;
			visited[u]=true;

			bool enqued=false;
			rep(v,n)if(!visited[v] && adj[u][v]<INF){
				qu.push(mp(v,len+adj[u][v]));
				enqued=true;
			}
			if(!enqued)	lmax=max(lmax,len);
		}

		int lsum=0;
		rep(u,n)rep(v,u) if(adj[u][v]<INF) lsum+=adj[u][v];
		printf("%d\n",2*lsum-lmax);
	}

	return 0;
}