#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 214748360

int main(){
  int n;
  while(cin>>n, n){
    vector<pair<int,int>> vec[20];
    vector<vector<int>> d(n, vector<int>(n, INF));
    bool isleaf[20];
    rep(i,n-1){
      int a,b,c;
      cin>>a>>b>>c;
      a--;b--;
      vec[a].pb(mp(b,c));
      vec[b].pb(mp(a,c));
      d[a][b] = d[b][a] = c;
    }
    rep(i,n) isleaf[i] = vec[i].size()==1;
    isleaf[0]=false;

    int total = 0;
    rep(i,n) if(!isleaf[i]) for(auto p : vec[i]){
      if(!isleaf[p.fi]) total += p.se;
    }

    rep(i,n) d[i][i]=0;
    rep(k,n)rep(i,n)rep(j,n) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
    int mx = 0;
    rep(i,n) if(!isleaf[i]) mx = max(mx, d[0][i]);

    cout << total - mx << endl;
  }
  return 0;
}