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
/*
	real time: 2021.7.7
	hh: 2021.5.9
	gugu: 2 months
*/
#include<bits/stdc++.h>
#define R register
#define N 1000201
#define ll long long
#define D double

int home[N],next[N],to[N],ans1,cnt,n,m;
D d[N],sm,ans2=1e18; ll sum[N],w[N];
int f[N],mxs,rt,sz[N],nc,vis[N];

inline void add(int a,int b,ll c){
	next[++cnt]=home[a],home[a]=cnt,to[cnt]=b,sum[cnt]=c;
}

inline void getrt(int x,int fa){
	f[x]=0,sz[x]=1;
	for(R int i=home[x];i;i=next[i]){
		R int v=to[i]; if(v==fa||vis[v]) continue;
		getrt(v,x); sz[x]+=sz[v]; f[x]=std::max(f[x],sz[v]);
	}
	f[x]=std::max(f[x],nc-sz[x]); if(f[x]<mxs) mxs=f[x],rt=x;
}

inline void dfs(int x,int o,ll dep,int fa){
	d[x]+=1.5*sqrt(dep)*w[x];
	sm+=sqrt(dep)*dep*w[x];
	for(R int i=home[x];i;i=next[i]){
		R int v=to[i];
		if(v==fa) continue; //注意需要遍历所有子树，所以不应该管vis标记刺
		dfs(v,o,dep+sum[i],x);
	}
}

inline void dvd(int x){
	vis[x]=1;
	sm=0;
	R D sd=0;
	for(R int i=home[x];i;i=next[i]){
		R int v=to[i];
//		if(vis[v]) continue;
		d[v]=0; dfs(v,v,sum[i],x); sd+=d[v];
	}
//	printf("sss %d\n",x);
//	std::cerr<<"!!!"<<sm<<'\n';
	if(sm<ans2) ans2=sm,ans1=x;
//	return;
	R int xs=0;
	for(R int i=home[x];i;i=next[i]){
		R int v=to[i];
		if(vis[v]) continue;
		if(sd-2*d[v]>=0) continue;
		mxs=100000000,nc=sz[v],rt=0;
		getrt(v,0);
		dvd(rt);
	}
}

int main(){
	scanf("%d",&n);
	for(R int i=1;i<=n;++i) scanf("%d",&w[i]);
	for(R int i=1,a,b,c;i<n;++i) scanf("%d%d%d",&a,&b,&c),add(a,b,c),add(b,a,c);
	nc=n,rt=0,mxs=100000000;
	getrt(1,0);
	dvd(rt);
	printf("%d %.10lf\n",ans1,ans2);
}