#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <complex>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
typedef pair<int,int> pr;
typedef vector<pr> vp;
queue<int> qu;
const int INF=1<<30;
vp bridge[100];
int search(int from,int now,bool ret){
	int minium=INF;
	if(ret){
		int sum=0;
		REP(j,bridge[now].size()){
			int next=bridge[now][j].second,dist=bridge[now][j].first;
			if(next==from) continue;
			if(bridge[next].size()==1) continue;
			sum+=search(now,next,1);
				sum+=dist;
			sum+=dist;
		}
		return sum;
	}
	REP(i,bridge[now].size()){
		if(bridge[now][i].second==from) continue;
		int sum=0;
		REP(j,bridge[now].size()){
			int next=bridge[now][j].second,dist=bridge[now][j].first;
			if(next==from) continue;
			if(bridge[next].size()==1) continue;
			sum+=search(now,next,i!=j);
			if(i!=j)
				sum+=dist;
			sum+=dist;
		}
		minium=min(minium,sum);
	}
	return minium;
}
int main() {
	int N,a,b,t;
	while(cin >> N && N){
	REP(i,N-1){
		cin >> a >> b >> t;
		bridge[a].push_back(pr(t,b));
		bridge[b].push_back(pr(t,a));
	}
	cout << search(0,1,0) << endl;
	REP(i,100)
		while(!bridge[i].empty()) bridge[i].pop_back();
	}
	// your code goes here
	return 0;
}