#include<iostream>
#define MAXN 32

using namespace std;

const int infty = 1<<24;

int dfs(int now, int n, int par[MAXN], bool vis[MAXN], bool leaf[MAXN], int W[MAXN][MAXN]){
  int ret = 0;
  int cnt = 0;
  vis[now]=true;
  for(int i = 0; i < n; ++i){
    if(W[now][i]>0 && !vis[i]){
      ret += 2*W[now][i];
      ++cnt;
      par[i]=now;
      ret += dfs(i,n,par,vis,leaf,W);
      if(leaf[i])
	ret -= 2*W[now][i];
    }
  }
  if(cnt==0)leaf[now]=true;
  return ret;
}

int solve(int n, int W[MAXN][MAXN]){
  int ret = infty;
  for(int i = 0; i < n; ++i){
    bool leaf[MAXN]={false,};
    bool vis[MAXN]={false,};
    int par[MAXN];
    int D = dfs(i,n,par,vis,leaf,W);

    int path0child = -1;
    if(i!=0){
      int c = 0;
      int p = par[c];
      while(true){
	if(!leaf[c]){
	  D -= W[c][p];
	}
	if(p==i){path0child=c;break;}
	c = p;
	p = par[c];
      }
      if(leaf[0]){
	D += W[par[0]][0];
      }
    }

    int maxD = 0;
    for(int j = 0; j < n; ++j){
      if( !leaf[j] && W[i][j] > 0 && j != path0child ){
	maxD = max(maxD, W[i][j]);
      }
    }
    
    ret = min( ret, D - maxD );
  }
  return ret;
}

int main()
{
  while(true){
    int n;
    int W[MAXN][MAXN]={{0,},}; // 0 means unconnected
    cin >> n;
    //cout << n << endl;
    if( n == 0 ) break;
    for(int i = 0; i < n-1; ++i){
      int a,b,t;
      cin >> a >> b >> t;
      --a;--b;
      W[a][b] = W[b][a] = t;
    }
    cout << solve(n,W) << endl;
  }
  return 0;
}