#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

int tbl[25][25];
int N;
int node[25];
int res;
int sum;
int maxt;

void dfs1 (int curr, int parent )
{
	bool found = false;

	rep (i, N ){
		if (i != curr && i != parent && tbl[curr][i] ){
			found = true;
//			cout << curr << " is middle node." << endl; 
			dfs1 (i, curr );
		} // end if
	} // end rep

	if (!found ){
//		cout << curr << " is leaf. " << endl;
		node[curr] = 1;
	} // end if
}

void dfs2 (int curr, int parent )
{
	rep (i, N ){
		if (i != parent && tbl[curr][i] && !node[i] ){
			res += tbl[curr][i];
			sum += tbl[curr][i];
//			cout << curr << " -> " << i << " sum:" << sum << endl;
			maxt = max (maxt, sum );
			dfs2 (i, curr );
			res += tbl[curr][i];
			sum -= tbl[curr][i];
		} // end if
	} // end rep
}		

int main()
{
//	cut here before submit 
//	freopen ("testcase.SR", "r", stdin );
	int n;
	while (cin >> n && n ){
		memset (tbl, 0, sizeof (tbl ) );
		memset (node, 0, sizeof (node ) );
		rep (i, n-1 ){
			int a, b, t;
			cin >> a >> b >> t;
			N = max (N, max (a, b ) );	
			a--; b--;
			tbl[a][b] = t;
			tbl[b][a] = t;
		} // end rep
		res = 0;
		maxt = 0;
		sum = 0;
		dfs1 (0, -1 );
		dfs2 (0, -1 );
		cout << res - maxt << endl;
	} // end loop
		
	return 0;
}