Problem: Some country consists of n cities, connected by a railroad network. The transport communication of the country is so advanced that the network consists of a minimum required number of (n - 1) bidirectional roads (in the other words, the graph of roads is a tree). The i-th road that directly connects cities ai and bi, has the length of li kilometers.

The transport network is served by a state transporting company FRR (Fabulous Rail Roads). In order to simplify the price policy, it offers a single ride fare on the train. In order to follow the route of length t kilometers, you need to pay <image> burles. Note that it is forbidden to split a long route into short segments and pay them separately (a special railroad police, or RRP, controls that the law doesn't get violated).

A Large Software Company decided to organize a programming tournament. Having conducted several online rounds, the company employees determined a list of finalists and sent it to the logistical department to find a place where to conduct finals. The Large Software Company can easily organize the tournament finals in any of the n cities of the country, so the the main factor in choosing the city for the last stage of the tournament is the total cost of buying tickets for all the finalists. We know that the i-th city of the country has wi cup finalists living there.

Help the company employees find the city such that the total cost of travel of all the participants to it is minimum.

Input

The first line of the input contains number n (1 ≤ n ≤ 200 000) — the number of cities in the country.

The next line contains n integers w1, w2, ..., wn (0 ≤ wi ≤ 108) — the number of finalists living in each city of the country.

Next (n - 1) lines contain the descriptions of the railroad, the i-th line contains three integers, ai, bi, li (1 ≤ ai, bi ≤ n, ai ≠ bi, 1 ≤ li ≤ 1000).

Output

Print two numbers — an integer f that is the number of the optimal city to conduct the competition, and the real number c, equal to the minimum total cost of transporting all the finalists to the competition. Your answer will be considered correct if two conditions are fulfilled at the same time: 

  1. The absolute or relative error of the printed number c in comparison with the cost of setting up a final in city f doesn't exceed 10 - 6; 
  2. Absolute or relative error of the printed number c in comparison to the answer of the jury doesn't exceed 10 - 6. 



If there are multiple answers, you are allowed to print any of them.

Examples

Input

5
3 1 2 6 5
1 2 3
2 3 1
4 3 9
5 3 1


Output

3 192.0

Input

2
5 5
1 2 2


Output

1 14.142135623730951000

Note

In the sample test an optimal variant of choosing a city to conduct the finals of the competition is 3. At such choice the cost of conducting is <image> burles.

In the second sample test, whatever city you would choose, you will need to pay for the transport for five participants, so you will need to pay <image> burles for each one of them.

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class VK15_FC {

	static int nV;

	static long[] w;

	static ArrayList<Integer>[] aList;
	static ArrayList<Integer>[] cList;

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		nV = Integer.parseInt(reader.readLine());

		w = new long[nV];
		StringTokenizer inputData = new StringTokenizer(reader.readLine());
		for (int i = 0; i < nV; i++) {
			w[i] = Integer.parseInt(inputData.nextToken());
		}

		aList = new ArrayList[nV];
		cList = new ArrayList[nV];
		for (int i = 0; i < nV; i++) {
			aList[i] = new ArrayList<>();
			cList[i] = new ArrayList<>();
		}

		for (int i = 0; i < nV - 1; i++) {
			inputData = new StringTokenizer(reader.readLine());
			int a = Integer.parseInt(inputData.nextToken()) - 1;
			int b = Integer.parseInt(inputData.nextToken()) - 1;
			int c = Integer.parseInt(inputData.nextToken());
			aList[a].add(b);
			aList[b].add(a);
			cList[a].add(c);
			cList[b].add(c);
		}

		vCount = new int[nV];
		removed = new boolean[nV];

		decompose(0);

		double sumGrad = 0;
		double lCost = fCost(last, -1, 0);

		int altV = -1;
		double aCost = 0;

		for (int aV : aList[last]) {
			sumGrad += fGrad(aV, last, 1);
		}

		for (int aV : aList[last]) {
			if (2 * fGrad(aV, last, 1) >= sumGrad) {
				altV = aV;
				aCost = fCost(aV, -1, 0);
			}
		}

		if (altV == -1 || lCost <= aCost) {
			printer.println(last + 1 + " " + lCost);
		} else {
			printer.println(altV + 1 + " " + aCost);
		}

		printer.close();
	}

	static double fCost(int cV, int pV, int len) {
		double sum = w[cV] * Math.pow(len, 1.5);

		for (int aI = 0; aI < aList[cV].size(); aI++) {
			int aV = aList[cV].get(aI);
			int cC = cList[cV].get(aI);
			if (aV != pV) {
				sum += fCost(aV, cV, len + cC);
			}
		}
		return sum;
	}

	static int[] vCount;

	static int gSize = 0;

	static boolean[] removed;

	// calculates the sum of derivatives/(3/2)
	static double fGrad(int cV, int pV, int len) {
		double sum = w[cV] * Math.sqrt(len);

		for (int aI = 0; aI < aList[cV].size(); aI++) {
			int aV = aList[cV].get(aI);
			int cC = cList[cV].get(aI);
			if (aV != pV) {
				sum += fGrad(aV, cV, len + cC);
			}
		}
		return sum;
	}

	static int last = -1;

	// whenever something has no par use -1

	// prerequisite: initialize vCount and par
	// the root can be any arbitrary vertex within that "group"
	static void decompose(int root) {
		fCount(root, -1);
		gSize = vCount[root];
		int centroid = fCentroid(root, -1);

		removed[centroid] = true;

		double sumGrad = 0;

		for (int aV : aList[centroid]) {
			sumGrad += fGrad(aV, centroid, 1);
		}

		for (int aV : aList[centroid]) {
			if (!removed[aV]) { // if removed it has been considered before and either is case second last or just worse
				if (2 * fGrad(aV, centroid, 1) >= sumGrad) {
					decompose(aV);
				}
			}
		}
		if (last == -1) {
			last = centroid;
		}
	}

	// prerequisite: fDegree has to be run on the "group" and gSize has to be set to vCount of root
	// returns centroid
	static int fCentroid(int cV, int pV) {
		dLoop:
		while (true) {
			for (int aV : aList[cV]) {
				if (!removed[aV] && aV != pV && vCount[aV] > gSize / 2) {
					pV = cV;
					cV = aV;
					continue dLoop;
				}
			}
			return cV;
		}
	}

	static void fCount(int cV, int pV) {
		vCount[cV] = 1;
		for (int aV : aList[cV]) {
			if (aV != pV && !removed[aV]) {
				fCount(aV, cV);
				vCount[cV] += vCount[aV];
			}
		}
	}

}