#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int N;
vector<P> G[20];
int used[20];

int dfs(int n) {
	used[n] = 1;
	int res = 0;
	for (auto p : G[n]) {
		if (G[p.first].size() > 1 && used[p.first] == 0) {
			res = max(res, dfs(p.first) + p.second);
		}
	}
	used[n] = 0;
	return res;
}

int main()
{
	int N;
	while (cin >> N, N) {
		for (int i = 0; i < 20; i++) {
			G[i].clear();
		}
		vector<int> a(N - 1), b(N - 1), t(N - 1);
		for (int i = 0; i < N - 1; i++) {
			cin >> a[i] >> b[i] >> t[i];
			G[a[i] - 1].push_back(P(b[i] - 1, t[i]));
			G[b[i] - 1].push_back(P(a[i] - 1, t[i]));
		}
		long long res = 0;
		for (int i = 0; i < N - 1; i++) {
			if (((G[a[i] - 1].size() > 1 || a[i] == 1) && (G[b[i] - 1].size() > 1 || b[i] == 1))) {
				res += t[i] * 2;
			}
		}
		res -= dfs(0);
		cout << res << endl;
	}
	return 0;
}