Valerian was captured by Shapur. The victory was such a great one that Shapur decided to carve a scene of Valerian's defeat on a mountain. So he had to find the best place to make his victory eternal!

He decided to visit all n cities of Persia to find the best available mountain, but after the recent war he was too tired and didn't want to traverse a lot. So he wanted to visit each of these n cities at least once with smallest possible traverse. Persian cities are connected with bidirectional roads. You can go from any city to any other one using these roads and there is a unique path between each two cities.

All cities are numbered 1 to n. Shapur is currently in the city 1 and he wants to visit all other cities with minimum possible traverse. He can finish his travels in any city.

Help Shapur find how much He should travel.

Input

First line contains a single natural number n (1 ≤ n ≤ 105) — the amount of cities.

Next n - 1 lines contain 3 integer numbers each xi, yi and wi (1 ≤ xi, yi ≤ n, 0 ≤ wi ≤ 2 × 104). xi and yi are two ends of a road and wi is the length of that road.

Output

A single integer number, the minimal length of Shapur's travel.

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

Examples

Input

3
1 2 3
2 3 4


Output

7


Input

3
1 2 3
1 3 3


Output

9
import java.util.List;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Nguyen Trung Hieu - vuondenthanhcong11@gmail.com
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskD {
    long answer = 0;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int count = in.readInt();
        Graph graph = new BidirectionalGraph(count);
        for (int i = 0; i < count - 1; i++) {
            Edge edge = new WeightedEdge(in.readInt() - 1, in.readInt() - 1, in.readInt());
            graph.add(edge);
            answer += edge.getWeight();
        }

        out.printLine(2 * answer - dfs(-1, 0, graph));
    }

    private long dfs(int from, int cur, Graph graph) {
        long curMax = 0;
        for (Edge edge : graph.getIncident(cur)) {
            if (edge.getDestination() == from)
                continue;
            curMax = Math.max(curMax, edge.getWeight() + dfs(cur, edge.getDestination(), graph));
        }
        return curMax;
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }

}

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object...objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

}

class Graph {
    private final int size;
    private final List<Edge>[] edges;

    public Graph(int size) {
        this.size = size;
        //noinspection unchecked
        edges = new List[size];
        for (int i = 0; i < size; i++)
            edges[i] = new ArrayList<Edge>();
    }

    public List<Edge> getIncident(int vertex) {
        return edges[vertex];
    }

    public void add(Edge edge) {
        edges[edge.getSource()].add(edge);
        edge = edge.getReverseEdge();
        if (edge != null)
            edges[edge.getSource()].add(edge);
    }

    //update 22-8-2013
}

class BidirectionalGraph extends Graph {
    public BidirectionalGraph(int size) {
        super(size);
    }

    public void add(Edge edge) {
        super.add(edge);
        super.add(edge.getTransposedEdge());
    }
}

interface Edge {
    public int getSource();
    public int getDestination();
    public long getWeight();

    public Edge getTransposedEdge();
    public Edge getReverseEdge();
}

class WeightedEdge extends SimpleEdge {
    private final long weight;

    public WeightedEdge(int source, int destination, long weight) {
        super(source, destination);
        this.weight = weight;
    }

    public long getWeight() {
        return weight;
    }

    public Edge getTransposedEdge() {
        if (transposed == null)
            transposed = new WeightedTransposedEdge();
        return transposed;
    }

    protected class WeightedTransposedEdge extends SimpleTransposedEdge {
        public long getWeight() {
            return weight;
        }
    }
}

class SimpleEdge implements Edge {
    protected final int source;
    protected final int destination;
    protected Edge transposed = null;

    public SimpleEdge(int source, int destination) {
        this.source = source;
        this.destination = destination;
    }

    public int getSource() {
        return source;
    }

    public int getDestination() {
        return destination;
    }

    public long getWeight() {
        return 1;
    }

    public Edge getTransposedEdge() {
        if (transposed == null)
            transposed = new SimpleTransposedEdge();
        return transposed;
    }

    public Edge getReverseEdge() {
        return null;
    }

    protected class SimpleTransposedEdge implements Edge {
        public int getSource() {
            return destination;
        }

        public int getDestination() {
            return source;
        }

        public long getWeight() {
            return 1;
        }

        public Edge getTransposedEdge() {
            return SimpleEdge.this;
        }

        public Edge getReverseEdge() {
            return null;
        }

    }
}
