#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;

struct edge
{
	int to;
	int cost;
};

int maxv = 0;
int total = 0;
vector<edge> G[21];
bool visited[21];

void dfs(int cur, int sum)
{
	for (int i = 0; i < G[cur].size(); ++i)
	{
		edge e = G[cur][i];
		if (G[e.to].size() > 1 && visited[e.to] == false)
		{
			visited[e.to] = true;
			maxv = max(maxv, sum + e.cost);
			total += e.cost;
			dfs(e.to, sum + e.cost);
		}
	}
}


void solve()
{
	int N;
	while (cin >> N, N)
	{
		for (int i = 0; i < N; ++i)
		{
			G[i].clear();
		}
		for (int i = 0; i < N - 1; ++i)
		{
			int a, b, t;
			cin >> a >> b >> t;
			--a;
			--b;
			edge e1, e2;
			e1.to = b;
			e2.to = a;
			e1.cost = e2.cost = t;
			G[a].push_back(e1);
			G[b].push_back(e2);
		}
		maxv = 0;
		total = 0;
		memset(visited, 0, sizeof(visited));
		visited[0] = true;
		dfs(0, 0);
		cout << 2 * total - maxv << endl;
	}
}

int main()
{
	solve();
	return(0);
}