Problem: A root tree is a directed acyclic graph that contains one node (root), from which there is exactly one path to any other node.

A root tree is binary if each node has at most two outgoing arcs.

When a binary tree is painted on the plane, all arcs should be directed from top to bottom. That is, each arc going from u to v must meet the condition yu > yv.

You've been given the coordinates of all tree nodes. Your task is to connect these nodes by arcs so as to get the binary root tree and make the total length of the arcs minimum. All arcs of the built tree must be directed from top to bottom.

Input

The first line contains a single integer n (2 ≤ n ≤ 400) — the number of nodes in the tree. Then follow n lines, two integers per line: xi, yi (|xi|, |yi| ≤ 103) — coordinates of the nodes. It is guaranteed that all points are distinct.

Output

If it is impossible to build a binary root tree on the given points, print "-1". Otherwise, print a single real number — the total length of the arcs in the minimum binary tree. The answer will be considered correct if the absolute or relative error doesn't exceed 10 - 6. 

Examples

Input

3
0 0
1 0
2 1


Output

3.650281539872885


Input

4
0 0
1 0
2 1
2 0


Output

-1

Solution (in JAVA):

Solution:


import java.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;

import static java.lang.Math.*;

// Solution is at the bottom of code

public class _E implements Runnable{
	
	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
	
	BufferedReader in;
	OutputWriter out;
	StringTokenizer tok = new StringTokenizer("");
	
	public static void main(String[] args){
		new Thread(null, new _E(), "", 128 * (1L << 20)).start();
	}
	
	/////////////////////////////////////////////////////////////////////
	
	void init() throws FileNotFoundException{
		Locale.setDefault(Locale.US);
		
		if (ONLINE_JUDGE){
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new OutputWriter(System.out);
		}else{
			in = new BufferedReader(new FileReader("input.txt"));
			out = new OutputWriter("output.txt");
		}
	}
	
	////////////////////////////////////////////////////////////////
	
	long timeBegin, timeEnd;

	void time(){
		timeEnd = System.currentTimeMillis();
		System.err.println("Time = " + (timeEnd - timeBegin));
	}
	
	void debug(Object... objects){
		if (ONLINE_JUDGE){
			for (Object o: objects){
				System.err.println(o.toString());
			}
		}
	}
	
	/////////////////////////////////////////////////////////////////////
	
	public void run(){
		try{
			timeBegin = System.currentTimeMillis();
			Locale.setDefault(Locale.US);
			
			init();
			solve();
			
			out.close();
			time();
		}catch (Exception e){
			e.printStackTrace(System.err);
			System.exit(-1);
		}
	}
	
	/////////////////////////////////////////////////////////////////////
	
	String delim = " ";
	
	String readString() throws IOException{
		while(!tok.hasMoreTokens()){
			try{
				tok = new StringTokenizer(in.readLine());
			}catch (Exception e){
				return null;
			}
		}
		
		return tok.nextToken(delim);
	}
	
	String readLine() throws IOException{
		return in.readLine();
	}
	
	/////////////////////////////////////////////////////////////////
	
	final char NOT_A_SYMBOL = '\0';
	
	char readChar() throws IOException{
		int intValue = in.read();
		
		if (intValue == -1){
			return NOT_A_SYMBOL;
		}
		
		return (char) intValue;
	}
	
	char[] readCharArray() throws IOException{
		return readLine().toCharArray();
	}
	
	/////////////////////////////////////////////////////////////////
	
	int readInt() throws IOException{
		return Integer.parseInt(readString());
	}
	
	int[] readIntArray(int size) throws IOException{
		int[] array = new int[size];
		
		for (int index = 0; index < size; ++index){
			array[index] = readInt();
		}
		
		return array;
	}
	
	///////////////////////////////////////////////////////////////////
	
	long readLong() throws IOException{
		return Long.parseLong(readString());
	}
	
	long[] readLongArray(int size) throws IOException{
		long[] array = new long[size];
		
		for (int index = 0; index < size; ++index){
			array[index] = readLong();
		}
		
		return array;
	}
	
	////////////////////////////////////////////////////////////////////
	
	double readDouble() throws IOException{
		return Double.parseDouble(readString());
	}
	
	double[] readDoubleArray(int size) throws IOException{
		double[] array = new double[size];
		
		for (int index = 0; index < size; ++index){
			array[index] = readDouble();
		}
		
		return array;
	}
	
	/////////////////////////////////////////////////////////////////////
	
	Point readPoint() throws IOException{
		return new Point(readInt(), readInt());
	}
	
	Point[] readPointArray(int size) throws IOException{
		Point[] array = new Point[size];
		
		for (int index = 0; index < size; ++index){
			array[index] = readPoint();
		}
		
		return array;
	}
	
	/////////////////////////////////////////////////////////////////////
	
	class OutputWriter extends PrintWriter{

		final int DEFAULT_PRECISION = 12;
		
		int precision;
		String format, formatWithSpace;
		
		{
			precision = DEFAULT_PRECISION;
			
			format = createFormat(precision);
			formatWithSpace = format + " ";
		}
		
		public OutputWriter(OutputStream out) {
			super(out);
		}

		public OutputWriter(String fileName) throws FileNotFoundException {
			super(fileName);
		}
		
		public int getPrecision() {
			return precision;
		}

		public void setPrecision(int precision) {
			this.precision = precision;
			
			format = createFormat(precision);
			formatWithSpace = format + " ";
		}
		
		private String createFormat(int precision){
			return "%." + precision + "f";
		}
		
		@Override
		public void print(double d){
			printf(format, d);
		}
		
		public void printWithSpace(double d){
			printf(formatWithSpace, d);
		}

		public void printAll(double...d){
			for (int i = 0; i < d.length - 1; ++i){
				printWithSpace(d[i]);
			}
			
			print(d[d.length - 1]);
		}
		
		@Override
		public void println(double d){
			printlnAll(d);
		}
		
		public void printlnAll(double... d){
			printAll(d);
			println();
		}
	}
	
	/////////////////////////////////////////////////////////////////////
	
	int[][] steps = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; 
	
	boolean check(int index, int lim){
		return (0 <= index && index < lim);
	}
	
	/////////////////////////////////////////////////////////////////////
	
	final class Edge{
		
		int from, to;
		int f, c;
		
		double cost;
		
		Edge invEdge;

		public Edge(int from, int to, int c, double cost) {
			super();
			this.from = from;
			this.to = to;
			this.f = 0;
			this.c = c;
			this.cost = cost;
			this.invEdge = null;
		}
	}
	
	int n, size;
	List<Edge>[] graph;
	
	double ans;
	
	double INF = Integer.MAX_VALUE;
	
	int[] maxF;
	
	double[] d;
	double[] phi;
	
	boolean[] used;
	
	Edge[] p;
	
	final void solve() throws IOException{
		n = readInt();
		
		size = 2 * n + 2;
		
		graph = new List[size];
		for (int i = 0; i < size; ++i){
			graph[i] = new ArrayList<Edge>();
		}
		
		int s = 2 * n;
		int t = 2 * n + 1;
		
		Point[] points = readPointArray(n);
		for (int i = 0; i < n; ++i){
			addEdge(s, i, 2, 0);
			
			Point pi = points[i];
			int curY = pi.y;
			
			for (int j = 0; j < n; ++j){
				Point pj = points[j];
				
				if (curY > pj.y){
					addEdge(i, j + n, 1, pi.distance(pj));
				}
			}
			
			addEdge(i + n, t, 1, 0);
		}
		
		initArrays();
		
		ans = 0;
		while (true){
			dijkstra(s, t);
			
			if (d[t] == INF){
				break;
			}
		}
		
		int count = 0;
		for (Edge e: graph[t]){
			Edge invE = e.invEdge;
			
			count += invE.f;
		}
		
		if (count == n - 1){
			out.println(ans);
		}else{
			out.println(-1);
		}
	}
	
	final void dijkstra(int s, int t){
		Arrays.fill(d, INF);
		d[s] = 0;
		
		Arrays.fill(p, null);
		
		Arrays.fill(maxF, size * size);
		
		Arrays.fill(used, false);
		
		while (true){
			int from = -1;
			
			for (int v = 0; v < size; ++v){
				if (used[v] || d[v] == INF) continue;
				
				if (from == -1 || d[from] > d[v]){
					from = v;
				}
			}
			
			if (from == -1) break;
			used[from] = true;
			
			for (Edge e: graph[from]){ 
				int to = e.to;
				
				if (used[to]) continue;
				if (e.c <= e.f) continue;
				
				double w = getW(e);
				if (d[to] > d[from] + w){
					maxF[to] = min(maxF[from], e.c - e.f);
					
					d[to] = d[from] + w;
					p[to] = e;
				}
			}
		}
		
		if (d[t] == INF){
			return;
		}
		
		for (int v = 0; v < size; ++v){
			phi[v] += d[v];
		}
		
//		ans += d[t] - phi[s] + phi[t];
		
		int cur = t;
		while (p[cur] != null){
			Edge e = p[cur];
			
			ans += e.cost * maxF[t];
			e.f += maxF[t];
			
			Edge invE = e.invEdge;
			invE.f -= maxF[t];
			
			cur = e.from;
		}
	}
	
	final double getW(Edge e){
		return e.cost + phi[e.from] - phi[e.to];
	}
	
	final void addEdge(int from, int to, int c, double cost){
		Edge eTo = new Edge(from, to, c, cost);
		Edge eFrom = new Edge(to, from, 0, -cost);
		
		eTo.invEdge = eFrom;
		eFrom.invEdge = eTo;
		
		graph[from].add(eTo);
		graph[to].add(eFrom);
	}
	
	final void initArrays() {
		maxF = new int[size];
		
		d = new double[size];
		phi = new double[size];
		
		p = new Edge[size];
		
		used = new boolean[size];
	}
}