#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	while(true) {
		int n;
		cin>>n;
		if(n == 0) break;
		vector<vector<pair<int, int> > > g(n);
		ll sum = 0;
		REP(i, n - 1) {
			int a, b, t;
			cin>>a>>b>>t;
			--a;
			--b;
			g[a].pb({b, t});
			g[b].pb({a, t});
			sum += t;
		}
		queue<int> q;
		vector<ll> d(n, INF);
		q.push(0);
		d[0] = 0;
		while(!q.empty()) {
			int p = q.front();
			q.pop();
			REP(i, g[p].size()) {
				if(d[g[p][i].first] == INF) {
					d[g[p][i].first] = d[p] + g[p][i].second;
					q.push(g[p][i].first);
				}
			}
		}
		vector<int> pai;
		REP(i, n) {
			if(g[i].size() == 1 && i != 0) {
				sum -= g[i][0].second;
				pai.pb(g[i][0].first);
			}
		}
		sum = sum * 2;
		ll hoge = 0;
		REP(i, pai.size()) {
			hoge = max(hoge, d[pai[i]]);
		}
		sum -= hoge;
		cout<<sum<<endl;
	}
}