import std.stdio;
import std.conv;
import std.algorithm;

class Node {
    Edge[] edges;
    string name;
    Node toTree(bool[Node] used) {
        used[this] = true;
        Node t = new Node;
        t.name = name;
        foreach (e; edges) {
            if (used.get(e.to, false)) continue;
            t.edges ~= new Edge(t, e.to.toTree(used), e.value);
        }
        return t;
    }
    override string toString() {
        return "Node " ~ name;
    }
}

class Edge {
    Node from, to;
    int value;
    this(Node from, Node to, int value) {
        this.from = from;
        this.to = to;
        this.value = value;
    }
}

int adfs(Node v) {
    int t = 0;
    foreach (e; v.edges) {
        t += adfs(e.to);
        if (e.to.edges.length > 0) {
            t += e.value * 2;
        }
    }
    return t;
}

int bdfs(Node v) {
    int x = adfs(v);
    int t = x;
    foreach (e; v.edges) {
        if (e.to.edges.length > 0) {
            t = min(t, x + (bdfs(e.to) + e.value) - (adfs(e.to) + e.value * 2));
        }
    }
    return t;
}

void main() {
    int N; 
    while (readf("%d\n", &N), N) {
        Node[] graph = new Node[N + 1];
        foreach (int i, ref _; graph) {
            _ = new Node;
            _.name = i.to!string;
        }
        foreach (i; 0 .. N - 1) {
            int a, b, t; readf("%d %d %d\n", &a, &b, &t);
            graph[a].edges ~= new Edge(graph[a], graph[b], t);
            graph[b].edges ~= new Edge(graph[b], graph[a], t);
        }
        Node tree = graph[1].toTree((bool[Node]).init);
        bdfs(tree).writeln;
    }
}