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.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.PrintWriter;
import java.io.OutputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Alex
 */
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();
	}
	static class TaskD{
		public void solve(int testNumber, InputReader in, OutputWriter out){
			int n = in.ri(); ArrayList<IntPair>[] edges = new ArrayList[n];
			for(int i = 0; i < edges.length; i++) edges[i] = new ArrayList(); for(int i = 0; i < n - 1; i++) {
				int x = in.ri() - 1, y = in.ri() - 1, w = in.ri(); edges[x].add(new IntPair(y, w));
				edges[y].add(new IntPair(x, w));
			} Pair<Long, Long> res = dfs(0, -1, edges); out.printLine(res.first * 2 - res.second);
		}
		Pair<Long, Long> dfs(int curcity, int prev, ArrayList<IntPair>[] edges){
			long total = 0, single = 0; for(IntPair edge : edges[curcity]) {
				if(edge.first != prev){
					Pair<Long, Long> temp = dfs(edge.first, curcity, edges); total += temp.first + edge.second;
					single = Math.max(single, temp.second + edge.second);
				}
			} return Pair.makePair(total, single);
		}
	}
	static class Pair<U, V> implements Comparable<Pair<U, V>>{
		public U first;
		public V second;
		public static <U, V> Pair<U, V> makePair(U first, V second){
			return new Pair<U, V>(first, second);
		}
		private Pair(U first, V second){
			this.first = first; this.second = second;
		}
		public boolean equals(Object o){
			if(this == o) return true; if(o == null || getClass() != o.getClass()) return false; Pair pair = (Pair) o;
			return !(first != null ? !first.equals(pair.first) : pair.first != null) && !(second != null ? !second.equals(pair.second) : pair.second != null);
		}
		public int hashCode(){
			int result = first != null ? first.hashCode() : 0;
			result = 31 * result + (second != null ? second.hashCode() : 0); return result;
		}
		public String toString(){
			return "(" + first + "," + second + ")";
		}
		@SuppressWarnings({"unchecked"})
		public int compareTo(Pair<U, V> o){
			int value = ((Comparable<U>) first).compareTo(o.first); if(value != 0) return value;
			return ((Comparable<V>) second).compareTo(o.second);
		}
	}
	static class IntPair implements Comparable<IntPair>{
		public int first;
		public int second;
		public IntPair(int first, int second){
			this.first = first; this.second = second;
		}
		public String toString(){
			return "(" + first + "," + second + ")";
		}
		public boolean equals(Object o){
			if(this == o) return true; if(o == null || getClass() != o.getClass()) return false;
			IntPair intPair = (IntPair) o; return first == intPair.first && second == intPair.second;
		}
		public int hashCode(){
			int result = first; result = 31 * result + second; return result;
		}
		public int compareTo(IntPair o){
			if(first < o.first) return -1; if(first > o.first) return 1; if(second < o.second) return -1;
			if(second > o.second) return 1; return 0;
		}
	}
	static class OutputWriter{
		private final PrintWriter writer;
		public OutputWriter(OutputStream outputStream){
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}
		public OutputWriter(Writer writer){
			this.writer = new PrintWriter(writer);
		}
		public void close(){
			writer.close();
		}
		public void printLine(long i){
			writer.println(i);
		}
	}
	static class InputReader{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private InputReader.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 ri(){
			return readInt();
		}
		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 isWhitespace(c);
		}
		public static boolean isWhitespace(int c){
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
		public interface SpaceCharFilter{
			public boolean isSpaceChar(int ch);
		}
	}
}

