#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MAX_N 20

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

struct Edge{
  int to, cost;
};

int N;
vector<vector<Edge> >G(MAX_N);
map<pi, int>m;
int g[32][32];

int dfs(int n, int prev, int v){
  if(G[n].size() == 1 && G[n][0].to == prev) return 0;
  int res = 0;
  rep(i, G[n].size()){
    int next = G[n][i].to;
    if(v >> next & 1) continue;
    v |= 1 << next;
    res += dfs(next, n, v);
  }

  return res + g[n][prev];
}

int root(int n, int prev, int v){
  //  printf("%d %d\n", n, prev);
  if(G[n].size() == 1 && G[n][0].to == prev) return 0;
  int res = 0;
  rep(i, G[n].size()){
    int next = G[n][i].to;
    if(v >> next & 1) continue;
    v |= 1 << next;
    res = max(res, root(next, n, v));
    //    printf("%d %d\n", next, res);
  }
  //  printf("%d %d %d\n", n, prev, res);
  return res + g[prev][n];
}

int main(){
  while(scanf("%d", &N) && N){
    rep(i, 32) rep(j, 32) g[i][j] = (i==j)?0:INF;
    rep(i, MAX_N) G[i].clear();
    m.clear();
    rep(i, N-1){
      int a, b, t;
      scanf("%d%d%d", &a, &b, &t); a--; b--;
      g[a][b] = g[b][a] = t;
      Edge e;
      e.to = b; e.cost = t;
      G[a].PB(e);
      e.to = a;
      G[b].PB(e);
    }

    //    printf("%d\n", dfs(0, 0, 0));
    //    printf("%d\n", root(0, 0, 0));
    printf("%d\n", 2*dfs(0, 0, 1)-root(0, 0, 1));
  }
  return 0;
}