3
1 1 5
1 3 42
1 2 42
 2
42 23
1 2 10
 10
45792697 27183921 4791060 77070594 27286110 66957065 19283638 2944837 26775511 65379701
5 8 25
8 10 94
1 4 14
9 7 96
4 2 16
2 6 58
2 3 99
6 8 21
8 9 87
 5
3 1 2 6 5
1 2 3
2 3 1
4 3 9
5 3 1
 10
26 31 21 57 56 44 54 58 79 97
2 1 277
1 8 91
1 7 380
4 1 649
10 5 799
10 1 940
8 6 627
6 3 177
9 6 685
 10
8 100 62 38 26 51 26 23 77 32
6 8 29
4 1 82
7 8 66
7 10 67
8 9 98
6 1 14
1 5 48
3 1 58
2 9 90
 2
23 42
1 2 10
 1
42
 3
1 5 1
1 3 42
1 2 42
 10
1 1 1 1 1 1 1 1 1 1
1 2 5
1 3 5
1 4 5
1 5 5
1 6 5
1 7 5
1 8 5
1 9 5
1 10 5
 3
1 1 1
1 2 42
2 3 42
 3
5 1 1
1 3 42
1 2 24

3 1042.0638260857 1 727.3238618387 6 283959805416.40496826
 3 192.0000000000 1 13952642.4776933547 8 544327.1927847408 2 727.3238618387 1 0.0000000000 2 1042.0638260857 1 100.6230589875 2 544.3822186663 1 389.7666169867
// CFFindMarble.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
//#define OFFLINE 1

#ifdef OFFLINE
#include <fstream>
#endif
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <set>
#include <map>


using namespace std;

typedef multimap<int, pair<int, int>> dist_map;
typedef pair<dist_map::iterator, dist_map::iterator> dist_map_eq;

void df(dist_map& m, int node, bool* viz, int *dist, int d, dist_map_eq* eq_iterators)
{
	viz[node] = true;
	dist[node] = d;

	dist_map_eq er = eq_iterators[node];

	for (dist_map::iterator it = er.first; it != er.second; ++it)
	{
		if (!viz[it->second.first])
			df(m, it->second.first, viz, dist, d + it->second.second, eq_iterators);
	}
}

int sum_dist(dist_map& m, int node, bool* viz, int *sig, int *dist, int n, dist_map_eq* eq_iterators)
{

	df(m, node, viz, dist, 0, eq_iterators);

	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		//sum += sig[i] * sqrt(dist[i] * dist[i] * dist[i]);
		sum += sig[i] * dist[i];
		viz[i] = false;
	}

	return sum;
}

void df_num_people(dist_map& m, int node, bool* viz, int* sig, long long* num_people_subtree, dist_map_eq* eq_iterators)
{
	viz[node] = true;
	long long num_people = sig[node];

	dist_map_eq er = eq_iterators[node];

	for (dist_map::iterator it = er.first; it != er.second; ++it)
	{
		if (!viz[it->second.first])
		{
			df_num_people(m, it->second.first, viz, sig, num_people_subtree, eq_iterators);
			num_people += num_people_subtree[it->second.first];
		}
	}

	num_people_subtree[node] = num_people;
}


void calc_num_people(dist_map& m, int node, bool* viz, int *sig, long long* num_people_subtree, int n, dist_map_eq* eq_iterators)
{
	df_num_people(m, node, viz, sig, num_people_subtree, eq_iterators);
	memset(viz, false, sizeof(bool) * n);
}

bool* clear_viz(bool* viz, int n)
{
	//memset(viz, false, sizeof(bool) * n);
	return viz;
}

pair<int, double> calc_min(dist_map& m, bool *viz, int n, int *sig, int *dist, dist_map_eq* eq_iterators)
{	
	bool *tried = new bool[n];
	memset(tried, 0, sizeof(bool) * n);
	long long *num_people_subtree = new long long[n];

	memset(num_people_subtree, 0, sizeof(int) * n);
	//calc_num_people(m, 0, viz, sig, num_people_subtree, n);

	int next_node = 0;
	int crt_node = next_node;

	while (next_node != -1)
	{		
		crt_node = next_node;
		tried[crt_node] = true;
		next_node = -1;		
		long long d = sum_dist(m, crt_node, clear_viz(viz, n), sig, dist, n, eq_iterators);
		calc_num_people(m, crt_node, viz, sig, num_people_subtree, n, eq_iterators);

		dist_map_eq er = eq_iterators[crt_node];
		for (dist_map::iterator it = er.first; it != er.second; ++it)
		{
			if (!tried[it->second.first])
			{
				//double d1 = sum_dist(m, it->second.first, clear_viz(viz, n), sig, dist, n);
				long long num_people_from_parent = num_people_subtree[crt_node];
				long long num_people_from_child = num_people_subtree[it->second.first];
				long long dt = (num_people_from_parent - (2 * num_people_from_child)) * it->second.second;
				if (d + dt < d)
				{
					d = d + dt;
					next_node = it->second.first;
				}
			}
		}		
	}

	return make_pair(crt_node, 0);
}

int get_ints(char* buffer, int* dest, int start)
{
	int index = start;
	int dindex = 0;
	int number = 0;

	while (buffer[index] != 0 && buffer[index] != '\r' && buffer[index] != '\n')
	{
		if (buffer[index] == ' ')
		{
			dest[dindex++] = number;
			number = 0;
		}
		else
			number = number * 10 + (buffer[index] - '0');

		index++;
	}
	dest[dindex++] = number;

	return index + 1;
}

int main()
{
	istream* is = &cin;
#ifdef OFFLINE
	ifstream ifs;
	ifs.open("in.txt", ifstream::in);
	is = &ifs;
#endif	

	int n;
	char *t = new char[10];
	is->getline(t, 10);
	get_ints(t, &n, 0);	
#ifdef OFFLINE
	//is->ignore(1);
#endif

	const int bsize = n * 30;
	char *buffer = new char[bsize];

	is->getline(buffer, bsize);
	int *sig = new int[n];
	get_ints(buffer, sig, 0);
	

	dist_map distances;
	is->getline(buffer, bsize, EOF);
	int *temp = new int[3];
	int idx = 0;
	for (int i = 0; i < n - 1; i++)
	{
#ifdef OFFLINE
		//is->ignore(1);
#endif
		//is->getline(buffer, bsize);
		idx = get_ints(buffer,  temp, idx);

		distances.insert(make_pair(temp[0] - 1, make_pair(temp[1] - 1, temp[2])));
		distances.insert(make_pair(temp[1] - 1, make_pair(temp[0] - 1, temp[2])));
	}

	dist_map_eq *eq_iterators = new dist_map_eq[n];
	for (int i = 0; i < n; i++)
	{
		eq_iterators[i] = distances.equal_range(i);
	}


	bool *viz = new bool[n];
	memset(viz, false, sizeof(bool) * n);
	int *dist = new int[n];
	pair<int, double> res = calc_min(distances, viz, n, sig, dist, eq_iterators);

	df(distances, res.first, clear_viz(viz, n), dist, 0, eq_iterators);

	double sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += sig[i] * sqrt((double)dist[i] * dist[i] * dist[i]);
	}

	cout << res.first + 1 << " " << fixed << setprecision(6) << sum;

	return 0;
}