#include <bits/stdc++.h>

#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define FOR(i, a, b) for (int i = (a), _end_ = (b); i <= _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define EXIT(...) printf(__VA_ARGS__), exit(0)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

using namespace std;

typedef long long LL;

template<typename T> T &Read(T &x)
{
	static char c;
	while (!isdigit(c = getchar()));
	x = c - '0';
	while (isdigit(c = getchar())) (x *= 10) += c - '0';
	return x;
}

const int maxn = 200000;

struct edge
{
	int id, g, nxt;

	edge() { }
	edge(const int &_id, const int &_g, const int &_nxt): id(_id), g(_g), nxt(_nxt) { }

};

edge e[(maxn << 1) + 5];
int en = 0;
int st[maxn + 5];

inline void add_edge(const int &x, const int &y, const int &z)
{
	e[en] = edge(y, z, st[x]), st[x] = en++;
}

inline void del_edge(const int &x, const int &y)
{
	for (int *i = st + x; *i != -1; i = &e[*i].nxt)
		if (e[*i].id == y)
		{
			*i = e[*i].nxt;
			break;
		}
}

int n;
int w[maxn + 5];

int ans;

double ansval;

int sz[maxn + 5];
int Max[maxn + 5];

int all[maxn + 5], alln = 0;

bool vis[maxn + 5];

void pre_dfs(const int &x, const int &f = -1)
{
	all[alln++] = x;
	sz[x] = 1;
	Max[x] = 0;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (y == f) continue;
		if (vis[y]) continue;
		pre_dfs(y, x);
		sz[x] += sz[y];
		Max[x] = max(Max[x], sz[y]);
	}
}

double sum = 0;
int dep[maxn + 5];

bool flag;

int rt;

void dfs(const int &x, const int &f = -1)
{
	sum += (double)w[x] * sqrt((double)dep[x]);
	if (x == rt) flag = 1;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (y == f) continue;
		if (vis[y]) continue;
		dep[y] = dep[x] + e[i].g;
		dfs(y, x);
	}
}

void calc(const int &x, const int &f = -1, const int &dep = 0)
{
	sum += (double)w[x] * dep * sqrt((double)dep);
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (y == f) continue;
		calc(y, x, dep + e[i].g);
	}
}

void update(const int &x)
{
	sum = 0;
	calc(x);
	if (ans == -1 || sum < ansval) ans = x, ansval = sum;
}

void work(const int &rt)
{
	::rt = rt;
	alln = 0;
	pre_dfs(rt);

	int x = -1;
	REP(i, 0, alln)
	{
		const int &y = all[i];
		Max[y] = max(Max[y], alln - sz[y]);
		if (x == -1 || Max[y] < Max[x]) x = y;
	}
	update(x);
	if (alln == 1) return;

	int rt_p = -1;
	int Max = -1;
	double Maxval;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (vis[y]) continue;
		dep[y] = e[i].g;
		sum = 0;
		flag = 0;
		dfs(y, x);
		if (flag)
		{
			rt_p = y;
			continue;
		}
		if (Max == -1 || sum > Maxval) Max = y, Maxval = y;
	}

	if (rt_p != -1)
	{
		sum = 0;
		if (Max >= 0) calc(Max);
		Maxval = sum;

		sum = 0;
		calc(rt_p);
		if (Max == -1 || sum < Maxval) Max = rt_p;
	}

	vis[x] = 1;
	work(Max);

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	memset(st, -1, sizeof st), en = 0;
	REP(i, 0, n) scanf("%d", w + i);
	REP(i, 0, n - 1)
	{
		static int x, y, z;
		scanf("%d%d%d", &x, &y, &z), --x, --y;
		add_edge(x, y, z), add_edge(y, x, z);
	}
	ans = -1;
	work(0);
	printf("%d ", ans + 1);
	printf("%.16f\n", ansval);
	return 0;
}


#include <bits/stdc++.h>

#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define FOR(i, a, b) for (int i = (a), _end_ = (b); i <= _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define EXIT(...) printf(__VA_ARGS__), exit(0)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

using namespace std;

typedef long long LL;

template<typename T> T &Read(T &x)
{
    static char c;
    while (!isdigit(c = getchar()));
    x = c - '0';
    while (isdigit(c = getchar())) (x *= 10) += c - '0';
    return x;
}

const int maxn = 200000;

struct edge
{
    int id, g, nxt;

    edge() { }
    edge(const int &_id, const int &_g, const int &_nxt): id(_id), g(_g), nxt(_nxt) { }

};

edge e[(maxn << 1) + 5];
int en = 0;
int st[maxn + 5];

inline void add_edge(const int &x, const int &y, const int &z)
{
    e[en] = edge(y, z, st[x]), st[x] = en++;
}

inline void del_edge(const int &x, const int &y)
{
    for (int *i = st + x; *i != -1; i = &e[*i].nxt)
        if (e[*i].id == y)
        {
            *i = e[*i].nxt;
            break;
        }
}

int n;
int w[maxn + 5];

int ans;

double ansval;

int sz[maxn + 5];
int Max[maxn + 5];

int all[maxn + 5], alln = 0;

bool vis[maxn + 5];

void pre_dfs(const int &x, const int &f = -1)
{
    all[alln++] = x;
    sz[x] = 1;
    Max[x] = 0;
    for (int i = st[x]; i != -1; i = e[i].nxt)
    {
        const int &y = e[i].id;
        if (y == f) continue;
        if (vis[y]) continue;
        pre_dfs(y, x);
        sz[x] += sz[y];
        Max[x] = max(Max[x], sz[y]);
    }
}

double sum = 0;
int dep[maxn + 5];

void dfs(const int &x, const int &f = -1)
{
    sum += (double)w[x] * sqrt((double)dep[x]);
    for (int i = st[x]; i != -1; i = e[i].nxt)
    {
        const int &y = e[i].id;
        if (y == f) continue;
        if (vis[y]) continue;
        dep[y] = dep[x] + e[i].g;
        dfs(y, x);
    }
}

double tmp[maxn + 5];

void calc(const int &x, const int &f = -1, const int &dep = 0)
{
    sum += (double)w[x] * dep * sqrt((double)dep);
    for (int i = st[x]; i != -1; i = e[i].nxt)
    {
        const int &y = e[i].id;
        if (y == f) continue;
        calc(y, x, dep + e[i].g);
    }
}

void update(const int &x)
{
    sum = 0;
    calc(x);
    if (ans == -1 || sum < ansval) ans = x, ansval = sum;
}

void work(const int &rt)
{
    alln = 0;
    pre_dfs(rt);

    int x = -1;
    REP(i, 0, alln)
    {
        const int &y = all[i];
        Max[y] = max(Max[y], alln - sz[y]);
        if (x == -1 || Max[y] < Max[x]) x = y;
    }
    update(x);
    if (alln == 1) return;

    double cnt = 0;
    for (int i = st[x]; i != -1; i = e[i].nxt)
    {
        const int &y = e[i].id;
        if (vis[y]) continue;
        dep[y] = e[i].g;
        sum = 0;
        dfs(y, x);
        cnt += sum;
        tmp[y] = sum;
    }

    int Min = -1;
    double Minval;
    for (int i = st[x]; i != -1; i = e[i].nxt)
    {
        const int &y = e[i].id;
        if (vis[y]) continue;
        double lyc = cnt - 2 * tmp[y];
        if (Min == -1 || lyc < Minval) Min = y, Minval = lyc;
    }

    vis[x] = 1;
    work(Min);

}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    scanf("%d", &n);
    memset(st, -1, sizeof st), en = 0;
    REP(i, 0, n) scanf("%d", w + i);
    REP(i, 0, n - 1)
    {
        static int x, y, z;
        scanf("%d%d%d", &x, &y, &z), --x, --y;
        add_edge(x, y, z), add_edge(y, x, z);
    }
    ans = -1;
    work(0);
    printf("%d ", ans + 1);
    printf("%.16f\n", ansval);
    return 0;
}


#include <bits/stdc++.h>

#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define FOR(i, a, b) for (int i = (a), _end_ = (b); i <= _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define EXIT(...) printf(__VA_ARGS__), exit(0)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

using namespace std;

typedef long long LL;

template<typename T> T &Read(T &x)
{
	static char c;
	while (!isdigit(c = getchar()));
	x = c - '0';
	while (isdigit(c = getchar())) (x *= 10) += c - '0';
	return x;
}

const int maxn = 200000;

struct edge
{
	int id, g, nxt;

	edge() { }
	edge(const int &_id, const int &_g, const int &_nxt): id(_id), g(_g), nxt(_nxt) { }

};

edge e[(maxn << 1) + 5];
int en = 0;
int st[maxn + 5];

inline void add_edge(const int &x, const int &y, const int &z)
{
	e[en] = edge(y, z, st[x]), st[x] = en++;
}

inline void del_edge(const int &x, const int &y)
{
	for (int *i = st + x; *i != -1; i = &e[*i].nxt)
		if (e[*i].id == y)
		{
			*i = e[*i].nxt;
			break;
		}
}

int n;
int w[maxn + 5];

int ans;

double ansval;

int sz[maxn + 5];
int Max[maxn + 5];

int all[maxn + 5], alln = 0;

bool vis[maxn + 5];

void pre_dfs(const int &x, const int &f = -1)
{
	all[alln++] = x;
	sz[x] = 1;
	Max[x] = 0;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (y == f) continue;
		if (vis[y]) continue;
		pre_dfs(y, x);
		sz[x] += sz[y];
		Max[x] = max(Max[x], sz[y]);
	}
}

double sum = 0;
int dep[maxn + 5];

void dfs(const int &x, const int &f = -1)
{
	sum += (double)w[x] * sqrt((double)dep[x]);
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (y == f) continue;
		if (vis[y]) continue;
		dep[y] = dep[x] + e[i].g;
		dfs(y, x);
	}
}

double tmp[maxn + 5];

void calc(const int &x, const int &f = -1, const int &dep = 0)
{
	sum += (double)w[x] * dep * sqrt((double)dep);
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (y == f) continue;
		calc(y, x, dep + e[i].g);
	}
}

void update(const int &x)
{
	sum = 0;
	calc(x);
	if (ans == -1 || sum < ansval) ans = x, ansval = sum;
}

void work(const int &rt)
{
	update(rt);
	alln = 0;
	pre_dfs(rt);

	int x = -1;
	REP(i, 0, alln)
	{
		const int &y = all[i];
		Max[y] = max(Max[y], alln - sz[y]);
		if (x == -1 || Max[y] < Max[x]) x = y;
	}
	update(x);
	if (alln == 1) return;

	double cnt = 0;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (vis[y]) continue;
		dep[y] = e[i].g;
		sum = 0;
		dfs(y, x);
		cnt += sum;
		tmp[y] = sum;
	}

	int Min = -1;
	double Minval = 1e100;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (vis[y]) continue;
		double lyc = cnt - 2 * tmp[y];
		if (Min == -1 || lyc < Minval) Min = y, Minval = lyc;
	}

	vis[x] = 1;
	work(Min);

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	memset(st, -1, sizeof st), en = 0;
	REP(i, 0, n) scanf("%d", w + i);
	REP(i, 0, n - 1)
	{
		static int x, y, z;
		scanf("%d%d%d", &x, &y, &z), --x, --y;
		add_edge(x, y, z), add_edge(y, x, z);
	}
	ans = -1;
	work(0);
	printf("%d ", ans + 1);
	printf("%.16f\n", ansval);
	return 0;
}


#include <bits/stdc++.h>

#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define FOR(i, a, b) for (int i = (a), _end_ = (b); i <= _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define EXIT(...) printf(__VA_ARGS__), exit(0)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

using namespace std;

typedef long long LL;

template<typename T> T &Read(T &x)
{
	static char c;
	while (!isdigit(c = getchar()));
	x = c - '0';
	while (isdigit(c = getchar())) (x *= 10) += c - '0';
	return x;
}

const int maxn = 200000;

struct edge
{
	int id, g, nxt;

	edge() { }
	edge(const int &_id, const int &_g, const int &_nxt): id(_id), g(_g), nxt(_nxt) { }

};

edge e[(maxn << 1) + 5];
int en = 0;
int st[maxn + 5];

inline void add_edge(const int &x, const int &y, const int &z)
{
	e[en] = edge(y, z, st[x]), st[x] = en++;
}

inline void del_edge(const int &x, const int &y)
{
	for (int *i = st + x; *i != -1; i = &e[*i].nxt)
		if (e[*i].id == y)
		{
			*i = e[*i].nxt;
			break;
		}
}

int n;
int w[maxn + 5];

int ans;

double ansval;

int sz[maxn + 5];
int Max[maxn + 5];

int all[maxn + 5], alln = 0;

bool vis[maxn + 5];

void pre_dfs(const int &x, const int &f = -1)
{
	all[alln++] = x;
	sz[x] = 1;
	Max[x] = 0;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (y == f) continue;
		if (vis[y]) continue;
		pre_dfs(y, x);
		sz[x] += sz[y];
		Max[x] = max(Max[x], sz[y]);
	}
}

double sum = 0;
int dep[maxn + 5];

bool flag;

int rt;

void dfs(const int &x, const int &f = -1)
{
	sum += (double)w[x] * sqrt((double)dep[x]);
	if (x == rt) flag = 1;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (y == f) continue;
		dep[y] = dep[x] + e[i].g;
		dfs(y, x);
	}
}

void calc(const int &x, const int &f = -1, const int &dep = 0)
{
	sum += (double)w[x] * dep * sqrt((double)dep);
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (y == f) continue;
		calc(y, x, dep + e[i].g);
	}
}

void update(const int &x)
{
	sum = 0;
	calc(x);
	if (ans == -1 || sum < ansval) ans = x, ansval = sum;
}

void work(const int &rt)
{
	::rt = rt;
	alln = 0;
	pre_dfs(rt);

	int x = -1;
	REP(i, 0, alln)
	{
		const int &y = all[i];
		Max[y] = max(Max[y], alln - sz[y]);
		if (x == -1 || Max[y] < Max[x]) x = y;
	}
	update(x);
	if (alln == 1) return;

	int Max = -1;
	double Maxval;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (vis[y]) continue;
		dep[y] = e[i].g;
		sum = 0;
		flag = 0;
		dfs(y, x);
		if (Max == -1 || sum > Maxval) Max = y, Maxval = sum;
		sum = 0;
		calc(y);
	}

	vis[x] = 1;
	work(Max);

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	memset(st, -1, sizeof st), en = 0;
	REP(i, 0, n) scanf("%d", w + i);
	REP(i, 0, n - 1)
	{
		static int x, y, z;
		scanf("%d%d%d", &x, &y, &z), --x, --y;
		add_edge(x, y, z), add_edge(y, x, z);
	}
	ans = -1;
	work(0);
	printf("%d ", ans + 1);
	printf("%.16f\n", ansval);
	return 0;
}


#include <bits/stdc++.h>

#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define FOR(i, a, b) for (int i = (a), _end_ = (b); i <= _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define EXIT(...) printf(__VA_ARGS__), exit(0)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

using namespace std;

typedef long long LL;

template<typename T> T &Read(T &x)
{
	static char c;
	while (!isdigit(c = getchar()));
	x = c - '0';
	while (isdigit(c = getchar())) (x *= 10) += c - '0';
	return x;
}

const int maxn = 200000;

struct edge
{
	int id, g, nxt;

	edge() { }
	edge(const int &_id, const int &_g, const int &_nxt): id(_id), g(_g), nxt(_nxt) { }

};

edge e[(maxn << 1) + 5];
int en = 0;
int st[maxn + 5];

inline void add_edge(const int &x, const int &y, const int &z)
{
	e[en] = edge(y, z, st[x]), st[x] = en++;
}

inline void del_edge(const int &x, const int &y)
{
	for (int *i = st + x; *i != -1; i = &e[*i].nxt)
		if (e[*i].id == y)
		{
			*i = e[*i].nxt;
			break;
		}
}

int n;
int w[maxn + 5];

int ans;

double ansval;

int sz[maxn + 5];
int Max[maxn + 5];

int all[maxn + 5], alln = 0;

bool vis[maxn + 5];

void pre_dfs(const int &x, const int &f = -1)
{
	all[alln++] = x;
	sz[x] = 1;
	Max[x] = 0;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (y == f) continue;
		if (vis[y]) continue;
		pre_dfs(y, x);
		sz[x] += sz[y];
		Max[x] = max(Max[x], sz[y]);
	}
}

double sum = 0;
int dep[maxn + 5];

bool flag;

int rt;

void dfs(const int &x, const int &f = -1)
{
	sum += (double)w[x] * sqrt((double)dep[x]);
	if (x == rt) flag = 1;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (y == f) continue;
		if (vis[y]) continue;
		dep[y] = dep[x] + e[i].g;
		dfs(y, x);
	}
}

double tmp[maxn + 5];

void calc(const int &x, const int &f = -1, const int &dep = 0)
{
	sum += (double)w[x] * dep * sqrt((double)dep);
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (y == f) continue;
		calc(y, x, dep + e[i].g);
	}
}

void update(const int &x)
{
	sum = 0;
	calc(x);
	if (ans == -1 || sum < ansval) ans = x, ansval = sum;
}

void work(const int &rt)
{
	::rt = rt;
	alln = 0;
	pre_dfs(rt);

	int x = -1;
	REP(i, 0, alln)
	{
		const int &y = all[i];
		Max[y] = max(Max[y], alln - sz[y]);
		if (x == -1 || Max[y] < Max[x]) x = y;
	}
	update(x);
	if (alln == 1) return;

	double cnt = 0;
	int rt_p = -1;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (vis[y]) continue;
		dep[y] = e[i].g;
		sum = 0;
		flag = 0;
		dfs(y, x);
		if (flag)
		{
			rt_p = y;
			continue;
		}
		cnt += sum;
		tmp[y] = sum;
	}

	int Min = -1;
	double Minval = 1e100;
	for (int i = st[x]; i != -1; i = e[i].nxt)
	{
		const int &y = e[i].id;
		if (vis[y]) continue;
		if (y == rt_p) continue;
		double lyc = cnt - 2 * tmp[y];
		if (Min == -1 || lyc < Minval) Min = y, Minval = lyc;
	}

	if (x != rt)
	{
		sum = 0;
		calc(Min);
		Minval = sum;

		sum = 0;
		calc(rt_p);
		if (sum < Minval) Min = rt_p, Minval = sum;
	}

	vis[x] = 1;
	work(Min);

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	memset(st, -1, sizeof st), en = 0;
	REP(i, 0, n) scanf("%d", w + i);
	REP(i, 0, n - 1)
	{
		static int x, y, z;
		scanf("%d%d%d", &x, &y, &z), --x, --y;
		add_edge(x, y, z), add_edge(y, x, z);
	}
	ans = -1;
	work(0);
	printf("%d ", ans + 1);
	printf("%.16f\n", ansval);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn=200005;
int n,w[Maxn];
struct Edge{
	int y,prev,z;
}e[Maxn<<1];
int elast[Maxn],ecnt;
char del[Maxn];
int ms[Maxn],sz[Maxn],rt;
int c;
double f[Maxn];
double ans;

inline void Build(int x,int y,int z)
{
	e[++ecnt]=(Edge){y,elast[x],z};
	elast[x]=ecnt;
}

inline void dfs_find(int u,int fa,int tot)
{
	sz[u]=1;
	ms[u]=0;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa&&!del[v]) {
			dfs_find(v,u,tot);
			sz[u]+=sz[v];
			ms[u]=max(ms[u],sz[v]);
		}
	}
	ms[u]=max(ms[u],tot-sz[u]);
	rt=ms[u]*2<=tot?u:rt;
}

inline void dfs_calc(int u,int fa,int d,double &f,double &g)
{
	f+=pow((double)d,1.5)*(double)w[u];
	g+=sqrt((double)d)*(double)w[u];
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa) {
			dfs_calc(v,u,d+e[i].z,f,g);
		}
	}
}

inline void konjac(int u,int tot)
{
	dfs_find(u,0,tot);
	del[u=rt]=1;
	double sum=0,gsum=0;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		f[v]=0;
		dfs_calc(v,u,e[i].z,sum,f[v]);
		gsum+=f[v];
	}
	if (ans>sum) {
		ans=sum;
		c=u;
	}
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (!del[v]&&gsum-f[v]-f[v]<0) {
			konjac(v,sz[v]<sz[u]?sz[v]:tot-sz[u]);
			return;
		}
	}
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) {
		scanf("%d",w+i);
	}
	for (int i=1;i<n;++i) {
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		Build(x,y,z);
		Build(y,x,z);
	}
	ans=1e100;
	konjac(1,n);
	printf("%d %.6lf\n",c,ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn=200005;
int n,w[Maxn];
struct Edge{
	int y,prev,z;
}e[Maxn<<1];
int elast[Maxn],ecnt;
char del[Maxn];
int ms[Maxn],sz[Maxn],rt;
int c;
double f[Maxn];
double ans;

inline void Build(int x,int y,int z)
{
	e[++ecnt]=(Edge){y,elast[x],z};
	elast[x]=ecnt;
}

inline void dfs_find(int u,int fa,int tot)
{
	sz[u]=1;
	ms[u]=0;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa&&!del[v]) {
			dfs_find(v,u,tot);
			sz[u]+=sz[v];
			ms[u]=max(ms[u],sz[v]);
		}
	}
	ms[u]=max(ms[u],tot-sz[u]);
	rt=ms[u]*2<=tot?u:rt;
}

inline void dfs_calc(int u,int fa,int d,double &f,double &g)
{
	f+=pow((double)d,1.5)*(double)w[u];
	g+=sqrt((double)d)*(double)w[u];
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa) {
			dfs_calc(v,u,d+e[i].z,f,g);
		}
	}
}

inline void konjac(int u,int tot)
{
	dfs_find(u,0,tot);
	del[u=rt]=1;
	double sum=0,gsum=0;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		f[v]=0;
		dfs_calc(v,u,e[i].z,sum,f[v]);
		gsum+=f[v];
	}
	if (sum>ans) return;
	ans=sum;
	c=u;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (!del[v]&&gsum-f[v]-f[v]<0) {
			konjac(v,sz[v]<sz[u]?sz[v]:tot-sz[u]);
			return;
		}
	}
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) {
		scanf("%d",w+i);
	}
	for (int i=1;i<n;++i) {
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		Build(x,y,z);
		Build(y,x,z);
	}
	ans=1e100;
	konjac(1,n);
	printf("%d %.6lf\n",c,ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int Maxn=200005;
int n,w[Maxn];
struct Edge{
	int y,prev,z;
}e[Maxn<<1];
int elast[Maxn],ecnt;
char del[Maxn];
int ms[Maxn],sz[Maxn],rt;
int c;
double f[Maxn];
double ans;

inline void Build(int x,int y,int z)
{
	e[++ecnt]=(Edge){y,elast[x],z};
	elast[x]=ecnt;
}

inline void dfs_find(int u,int fa,int tot)
{
	sz[u]=1;
	ms[u]=0;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa&&!del[v]) {
			dfs_find(v,u,tot);
			sz[u]+=sz[v];
			ms[u]=max(ms[u],sz[v]);
		}
	}
	ms[u]=max(ms[u],tot-sz[u]);
	rt=ms[u]*2<=tot?u:rt;
}

inline void dfs_calc(int u,int fa,int d,double &f,double &g)
{
	f+=pow((double)d,1.5)*(double)w[u];
	g+=sqrt((double)d)*1.5*(double)w[u];
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa) {
			dfs_calc(v,u,d+e[i].z,f,g);
		}
	}
}

inline void konjac(int u,int tot)
{
	dfs_find(u,0,tot);
	del[u=rt]=1;
	double sum=0,gsum=0;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		f[v]=0;
		dfs_calc(v,u,e[i].z,sum,f[v]);
		gsum+=f[v];
	}
	if (sum>ans) return;
	ans=sum;
	c=u;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (!del[v]&&gsum-f[v]-f[v]<0) {
			konjac(v,sz[v]<sz[u]?sz[v]:tot-sz[u]);
			return;
		}
	}
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) {
		scanf("%d",w+i);
	}
	for (int i=1;i<n;++i) {
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		Build(x,y,z);
		Build(y,x,z);
	}
	ans=1e100;
	konjac(1,n);
	printf("%d %.6lf\n",c,ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int Maxn=200005;
int n,w[Maxn];
struct Edge{
	int y,prev,z;
}e[Maxn<<1];
int elast[Maxn],ecnt;
int c,len[Maxn];
ll sz[Maxn],sum;
long double ans;

inline void Build(int x,int y,int z)
{
	e[++ecnt]=(Edge){y,elast[x],z};
	elast[x]=ecnt;
}

inline void dfs_find(int u,int fa)
{
	sz[u]=w[u];
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa) {
			dfs_find(v,u);
			sz[u]+=sz[v];
		}
	}
	if (!c&&sz[u]*2>=sum) c=u;
}

inline void dfs_calc(int u,int fa)
{
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa) {
			len[v]=len[u]+e[i].z;
			dfs_calc(v,u);
		}
	}
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) {
		scanf("%d",w+i);
		sum+=w[i];
	}
	for (int i=1;i<n;++i) {
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		Build(x,y,z);
		Build(y,x,z);
	}
	dfs_find(1,0);
	dfs_calc(c,0);
	for (int i=1;i<=n;++i) {
		ans+=pow((long double)len[i],1.5)*w[i];
	}
	printf("%d %.6lf\n",c,(double)ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int Maxn=200005;
int n,w[Maxn];
struct Edge{
	int y,prev,z;
}e[Maxn<<1];
int elast[Maxn],ecnt;
char del[Maxn];
int ms[Maxn],sz[Maxn],rt;
int c;
double f[Maxn];
double ans;

inline void Build(int x,int y,int z)
{
	e[++ecnt]=(Edge){y,elast[x],z};
	elast[x]=ecnt;
}

inline void dfs_find(int u,int fa,int tot)
{
	sz[u]=1;
	ms[u]=0;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa) {
			dfs_find(v,u,tot);
			sz[u]+=sz[v];
			ms[u]=max(ms[u],sz[v]);
		}
	}
	ms[u]=max(ms[u],tot-sz[u]);
	rt=ms[u]*2<=tot?u:rt;
}

inline void dfs_calc(int u,int fa,int d,double &f,double &g)
{
	f+=pow((double)d,1.5)*(double)w[u];
	g+=sqrt((double)d)*1.5*(double)w[u];
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa) {
			dfs_calc(v,u,d+e[i].z,f,g);
		}
	}
}

inline void konjac(int u,int tot)
{
	dfs_find(u,0,tot);
	del[u=rt]=1;
	double sum=0,gsum=0;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		f[v]=0;
		dfs_calc(v,u,e[i].z,sum,f[v]);
		gsum+=f[v];
	}
	if (sum>=ans) return;
	ans=sum;
	c=u;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (!del[v]&&sum-f[v]-f[v]<0) {
			konjac(v,sz[v]<sz[u]?sz[v]:tot-sz[u]);
			return;
		}
	}
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) {
		scanf("%d",w+i);
	}
	for (int i=1;i<n;++i) {
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		Build(x,y,z);
		Build(y,x,z);
	}
	ans=1e100;
	konjac(1,n);
	printf("%d %.6lf\n",c,ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

char rr[1<<22],*csy1,*csy2;
#define GC (csy1==csy2&&(csy2=(csy1=rr)+fread(rr,1,1<<22,stdin),csy1==csy2)?EOF:*csy1++)

template <class T>
inline void RI(T &t)
{
	char c=GC;
	for (t=0;c<48||c>57;c=GC);
	for (;c>47&&c<58;c=GC) t=(t<<1)+(t<<3)+c-48;
}

const int Maxn=200005;
int n,w[Maxn];
struct Edge{
	int y,prev,z;
}e[Maxn<<1];
int elast[Maxn],ecnt;
char del[Maxn];
int ms[Maxn],sz[Maxn],rt;
int c;
double f[Maxn],ans;

inline void Build(int x,int y,int z)
{
	e[++ecnt]=(Edge){y,elast[x],z};
	elast[x]=ecnt;
}

inline void dfs_find(int u,int fa,int tot)
{
	sz[u]=1;
	ms[u]=0;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa&&!del[v]) {
			dfs_find(v,u,tot);
			sz[u]+=sz[v];
			ms[u]=max(ms[u],sz[v]);
		}
	}
	ms[u]=max(ms[u],tot-sz[u]);
	rt=ms[u]*2<=tot?u:rt;
}

inline void dfs_calc(int u,int fa,int d,double &f,double &g)
{
	double tmp=sqrt((double)d)*w[u];
	f+=tmp*d;
	g+=tmp;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa) {
			dfs_calc(v,u,d+e[i].z,f,g);
		}
	}
}

inline void konjac(int u,int tot)
{
	dfs_find(u,0,tot);
	del[u=rt]=1;
	double sum=0,gsum=0;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		f[v]=0;
		dfs_calc(v,u,e[i].z,sum,f[v]);
		gsum+=f[v];
	}
	if (ans>sum) {
		ans=sum;
		c=u;
	}
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (!del[v]&&gsum-f[v]-f[v]<0) {
			konjac(v,sz[v]<sz[u]?sz[v]:tot-sz[u]);
			return;
		}
	}
}

int main()
{
	RI(n);
	for (int i=1;i<=n;++i) {
		RI(w[i]);
	}
	for (int i=1;i<n;++i) {
		int x,y,z;
		RI(x);RI(y);RI(z);
		Build(x,y,z);
		Build(y,x,z);
	}
	ans=1e100;
	konjac(1,n);
	printf("%d %.6lf\n",c,ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

char rr[1<<22],*csy1,*csy2;
#define GC (csy1==csy2&&(csy2=(csy1=rr)+fread(rr,1,1<<22,stdin),csy1==csy2)?EOF:*csy1++)

template <class T>
inline void RI(T &t)
{
	char c=GC;
	for (t=0;c<48||c>57;c=GC);
	for (;c>47&&c<58;c=GC) t=(t<<1)+(t<<3)+c-48;
}

const int Maxn=200005;
int n,w[Maxn];
struct Edge{
	int y,prev,z;
}e[Maxn<<1];
int elast[Maxn],ecnt;
char del[Maxn];
int ms[Maxn],sz[Maxn],rt;
int c;
double f[Maxn];
double ans;

inline void Build(int x,int y,int z)
{
	e[++ecnt]=(Edge){y,elast[x],z};
	elast[x]=ecnt;
}

inline void dfs_find(int u,int fa,int tot)
{
	sz[u]=1;
	ms[u]=0;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa&&!del[v]) {
			dfs_find(v,u,tot);
			sz[u]+=sz[v];
			ms[u]=max(ms[u],sz[v]);
		}
	}
	ms[u]=max(ms[u],tot-sz[u]);
	rt=ms[u]*2<=tot?u:rt;
}

inline void dfs_calc(int u,int fa,int d,double &f,double &g)
{
	f+=pow((double)d,1.5)*(double)w[u];
	g+=sqrt((double)d)*(double)w[u];
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (v!=fa) {
			dfs_calc(v,u,d+e[i].z,f,g);
		}
	}
}

inline void konjac(int u,int tot)
{
	dfs_find(u,0,tot);
	del[u=rt]=1;
	double sum=0,gsum=0;
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		f[v]=0;
		dfs_calc(v,u,e[i].z,sum,f[v]);
		gsum+=f[v];
	}
	if (ans>sum) {
		ans=sum;
		c=u;
	}
	for (int i=elast[u];i;i=e[i].prev) {
		int v=e[i].y;
		if (!del[v]&&gsum-f[v]-f[v]<0) {
			konjac(v,sz[v]<sz[u]?sz[v]:tot-sz[u]);
			return;
		}
	}
}

int main()
{
	RI(n);
	for (int i=1;i<=n;++i) {
		RI(w[i]);
	}
	for (int i=1;i<n;++i) {
		int x,y,z;
		RI(x);RI(y);RI(z);
		Build(x,y,z);
		Build(y,x,z);
	}
	ans=1e100;
	konjac(1,n);
	printf("%d %.6lf\n",c,ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 200000 + 10;

int n;
int w[N], dis[N], sz[N];
bool ok[N];
double val[N];
vector<pair<int, int> > e[N];

void dfs_sz(int u, int p) {
    sz[u] = 1;
    for(auto it : e[u]) {
        int v = it.first;
        if(v == p || !ok[v])    continue;

        dfs_sz(v, u);
        sz[u] += sz[v];
    }
}

void find_gp(int u, int p, int x, int &mn, int &gp) {
    int tmp = x-sz[u];
    for(auto it : e[u]) {
        int v = it.first;
        if(v == p || !ok[v])    continue;

        find_gp(v, u, x, mn, gp);
        tmp = max(tmp, sz[v]);
    }
    if(mn > tmp) {
        mn = tmp;
        gp = u;
    }
}

void get_dis(int u) {
    for(auto it : e[u]) {
        int v = it.first, c = it.second;
        if(dis[v] != -1)  continue;

        dis[v] = dis[u]+c;
        get_dis(v);
    }
}

double calc_ans(int u, int p) {
    double ret = dis[u] * sqrt(dis[u]) * w[u];
    for(auto it : e[u]) {
        int v = it.first;
        if(v == p)  continue;

        ret += calc_ans(v, u);
    }
    return ret;
}

void calc_val(int u, int p) {
    val[u] = sqrt(dis[u])*w[u];
    for(auto it : e[u]) {
        int v = it.first;
        if(v == p || !ok[v])    continue;

        calc_val(v, u);
        val[u] += val[v];
    }
}

void ShuFanZhi(int u, int &bestv, double &ans) {
    fill(sz, sz+n+1, -1);
    dfs_sz(u, u);
    int gp = u, mn = sz[u];
    find_gp(u, u, sz[u], mn, gp);

    ok[gp] = false;
    fill(dis, dis+n+1, -1);
    dis[gp] = 0;
    get_dis(gp);
    double tmp = calc_ans(gp, gp);
    if(bestv == -1 || tmp < ans) {
        ans = tmp;
        bestv = gp;
    }

    calc_val(gp, gp);
    int nxt = -1;
    for(auto it : e[gp]) {
        int v = it.first;
        if(!ok[v])  continue;

        if(nxt == -1 || val[v] > val[nxt])
            nxt = v;
    }

    if(nxt != -1)   ShuFanZhi(nxt, bestv, ans);
}

int main() {
    scanf("%d", &n);
    for(int i=1; i<=n; i++)  scanf("%d", w+i);
    for(int i=0; i<n-1; i++) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);

        e[a].push_back(make_pair(b, c));
        e[b].push_back(make_pair(a, c));
    }

    double ans;
    int bestv = -1;
    fill(ok, ok+n+1, true);
    ShuFanZhi(1, bestv, ans);
    printf("%d %.10f\n", bestv, ans);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
const int MX = 200005;

int N, ip[MX];
vector<pii> E[MX];
int fr, bk, que[MX], vst[MX], fa[MX], sz[MX], ok[MX];
LL dis[MX];
int bestid = -1;
double ans = 1e20, val[MX];

bool BFS(int st) {
    fr = bk = 0;
    que[bk++] = st;
    vst[st] = 1;
    fa[st] = st;
    dis[st] = 0;
    while (fr < bk) {
        int u = que[fr++];
        for (auto it : E[u]) {
        	int v = it.first, w = it.second;
            if (!ok[v] || vst[v]) continue;
            que[bk++] = v;
            vst[v] = 1;
            dis[v] = dis[u] + w;
            fa[v] = u;
        }
    }
    for (int i=0; i<bk; i++) {
        vst[que[i]] = 0;
    }
}
int findCentroid(int st) {
    int ret = -1, cost = 1029384756;
    BFS(st);
    for (int i=bk-1; i>=0; i--) {
        int u = que[i], mx = 0;
        sz[u] = 1;
        for (auto it : E[u]) {
        	int v = it.first;
            if (!ok[v] || v == fa[u]) continue;
            sz[u] += sz[v];
            mx = max(mx, sz[v]);
        }
        mx = max(mx, bk-sz[u]);
        if (mx < cost) {
            cost = mx;
            ret = u;
        }
    }
    return ret;
}
double calcAnswer(int st) {
	double ret = 0;
	memset(dis, -1, sizeof(dis));
	fr = bk = 0;
	que[bk++] = st;
	dis[st] = 0;
	fa[st] = st;
	while (fr < bk) {
		int u = que[fr++];
		ret += dis[u] * sqrt(dis[u]) * ip[u];
		for (auto it : E[u]) {
			int v = it.first, w = it.second;
			if (dis[v] != -1) continue;
			fa[v] = u;
			dis[v] = dis[u] + w;
			que[bk++] = v;
		}
	}
	for (int i=bk-1; i>=0; i--) {
		int u = que[i];
		double tmp = dis[u] * sqrt(dis[u]) * ip[u];
		for (auto it : E[u]) {
			int v = it.first;
			if (v == fa[u]) continue;
			tmp += val[v];
		}
		val[u] = tmp;
	}
	return ret;
}

void go(int st) {
	int cent = findCentroid(st);
	ok[cent] = 0;
	double tmp = calcAnswer(cent);
	if (ans > tmp) {
		ans = tmp;
		bestid = cent;
	}
	int nxt = -1;
	for (auto it : E[cent]) {
		int v = it.first;
		if (!ok[v]) continue;
		if (nxt == -1 || val[v] > val[nxt]) {
			nxt = v;
		}
	}
	if (nxt != -1) {
		go(nxt);
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> N;
	for (int i=1; i<=N; i++) {
		cin >> ip[i];
	}
	for (int i=2, u, v, w; i<=N; i++) {
		cin >> u >> v >> w;
		E[u].push_back(make_pair(v, w));
		E[v].push_back(make_pair(u, w));
	}
	for (int i=1; i<=N; i++) {
		ok[i] = 1;
	}
	go(1);
	cout << bestid << " " << fixed << setprecision(10) << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 200000 + 10;

int n;
int w[N],  sz[N];
long long dis[N];
bool ok[N];
double val[N];
vector<pair<int, int> > e[N];

void dfs_sz(int u, int p) {
    sz[u] = 1;
    for(auto it : e[u]) {
        int v = it.first;
        if(v == p || !ok[v])    continue;

        dfs_sz(v, u);
        sz[u] += sz[v];
    }
}

void find_gp(int u, int p, int x, int &mn, int &gp) {
    int tmp = x-sz[u];
    for(auto it : e[u]) {
        int v = it.first;
        if(v == p || !ok[v])    continue;

        find_gp(v, u, x, mn, gp);
        tmp = max(tmp, sz[v]);
    }
    if(mn > tmp) {
        mn = tmp;
        gp = u;
    }
}

void get_dis(int u) {
    for(auto it : e[u]) {
        int v = it.first, c = it.second;
        if(dis[v] != -1)  continue;

        dis[v] = dis[u]+c;
        get_dis(v);
    }
}

double calc_ans(int u, int p) {
    double ret = dis[u] * sqrt(dis[u]) * w[u];
    for(auto it : e[u]) {
        int v = it.first;
        if(v == p)  continue;

        ret += calc_ans(v, u);
    }
    return ret;
}

void calc_val(int u, int p) {
    val[u] = sqrt(dis[u])*w[u];
    for(auto it : e[u]) {
        int v = it.first;
        if(v == p)    continue;

        calc_val(v, u);
        val[u] += val[v];
    }
}

void ShuFanZhi(int u, int &bestv, double &ans) {
    fill(sz, sz+n+1, -1);
    dfs_sz(u, u);
    int gp = u, mn = sz[u];
    find_gp(u, u, sz[u], mn, gp);

    ok[gp] = false;
    fill(dis, dis+n+1, -1);
    dis[gp] = 0;
    get_dis(gp);
    double tmp = calc_ans(gp, gp);
    if(bestv == -1 || tmp < ans) {
        ans = tmp;
        bestv = gp;
    }

    calc_val(gp, gp);
    int nxt = -1;
    for(auto it : e[gp]) {
        int v = it.first;
        if(!ok[v])  continue;

        if(nxt == -1 || val[v] > val[nxt])
            nxt = v;
    }

    if(nxt != -1)   ShuFanZhi(nxt, bestv, ans);
}

int main() {
    scanf("%d", &n);
    for(int i=1; i<=n; i++)  scanf("%d", w+i);
    for(int i=0; i<n-1; i++) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);

        e[a].push_back(make_pair(b, c));
        e[b].push_back(make_pair(a, c));
    }

    double ans;
    int bestv = -1;
    fill(ok, ok+n+1, true);
    ShuFanZhi(1, bestv, ans);
    printf("%d %.10f\n", bestv, ans);

    return 0;
}


#if 0
date

流皮流皮
#endif
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
} read;

const int maxn = 200005;
// int head[maxn], nxt[maxn << 1], to[maxn << 1], len[maxn << 1], hp = 1;
struct Edge {
	int to, w;
};
std::vector<Edge> G[maxn];
int val[maxn];

bool vis[maxn];
int size[maxn];
int cen, csize;
void get(int u, int n) {
	size[u] = 1;
	int now = 0;
	vis[u] = 1;
	for(Edge e : G[u])
		if(!vis[e.to]) {
			get(e.to, n);
			size[u] += size[e.to];
			now = std::max(now, size[e.to]);
		}
	vis[u] = 0;
	now = std::max(now, n - size[u]);
	if(now < csize) {
		cen = u;
		csize = now;
	}
}

int dis[maxn];
double sq[maxn];
void dfs(int u, int fa) {
	sq[u] = sqrt(dis[u]) * val[u];
	for(Edge e : G[u])
		if(e.to != fa) {
			dis[e.to] = dis[u] + e.w;
			dfs(e.to, u);
			sq[u] += sq[e.to];
		}
}

int divi(int s, int n) {
	csize = 1000000000;
	get(s, n);
	int u = cen;
	// debug("divi %d get %d\n", s, u);

	dis[u] = 0;
	dfs(u, 0);

	int to = 0;
	for(Edge e : G[u])
		if(!vis[e.to] and sq[u] - sq[e.to] * 2 < 0)
				to = e.to;
	if(!to) return u;

	vis[u] = 1;
	if(size[to] < size[u])
		return divi(to, size[to]);
	return divi(to, n - size[u]);
}

int main() {
	int n = read;
	for(int i = 1; i <= n; i ++)
		val[i] = read;

	for(int i = 1; i < n; i ++) {
		int u = read, v = read, w = read;
		G[u].push_back({v, w});
		G[v].push_back({u, w});
	}

	int u = divi(1, n);
	dfs(u, 0);
	double ans = 0;
	for(int i = 1; i <= n; i ++)
		ans += dis[i] * sqrt(dis[i]) * val[i];
	printf("%d %.7lf\n", u, ans);
}


#if 0
2020.01.29

考虑链的情况，把链看做数轴，
那么对于点 u 有 g(x) = dis(u, x)^1.5 ，g 是下凸函数。
设 f(x) 为所有这样的 g(x) 乘上点权的和，那么 f 也是下凸函数。
而题目要求的就是使得 f(x) 最小的点，在数轴上可以三分。

推广到树，每个点 u 同样有 g(x) = dis(u, x)^1.5 ，这里 x 是可以取在边上的。
类似地有在一个方向上 x 离 u 越远 g(x) 越大，g 是在树意义下的“下凸函数”，
同样定义 f(x) ，那么 f 也是树意义下的“下凸函数”，
换言之存在一个点 x 使 f(x) 取到最小值，在一个反向上离 x 越远 f 取值越大。

将三分推广到树上，
链上三分就是每次找到当前区间中点，然后考虑向相邻两点移动是否会更优。
树上自然就是每次找到当前子树重心，然后考虑向所有儿子移动是否会更优。
但是有一个明显的问题是一个点的儿子数量会很多，每个暴力检查一遍复杂度会退化。

当前重心为 u ，考虑儿子 v 是否会更优，其中 dis(u, v) = w 。
把 u - v 这条边放在数轴上，在这个数轴上定义 f(x) ，其中横坐标 x 是离 u 的距离。
那么只需要判断 u 向 v 移动一点点是否能让 f 取值变小即可。
也就是求 f 在 x = 0 处的导数是否小于 0 。
而这个导数是很好算的，只需要对 u 暴力 dfs 预处理一次即可。

需要注意的是该点导数小于 0 不一定说明 v 比 u 优，
可能是最优点在 u - v 边上面，这时候两边暴力检查即可。
#endif
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
} read;

const int maxn = 200005;
// int head[maxn], nxt[maxn << 1], to[maxn << 1], len[maxn << 1], hp = 1;
struct Edge {
	int to, w;
};
std::vector<Edge> G[maxn];
int val[maxn];

bool vis[maxn];
int size[maxn];
int cen, csize;
void get(int u, int n) {
	size[u] = 1;
	int now = 0;
	vis[u] = 1;
	for(Edge e : G[u])
		if(!vis[e.to]) {
			get(e.to, n);
			size[u] += size[e.to];
			now = std::max(now, size[e.to]);
		}
	vis[u] = 0;
	now = std::max(now, n - size[u]);
	if(now < csize) {
		cen = u;
		csize = now;
	}
}

int dis[maxn];
double sq[maxn], sum;
void dfs(int u, int fa) {
	sq[u] = sqrt(dis[u]) * val[u];
	sum += sq[u] * dis[u];
	for(Edge e : G[u])
		if(e.to != fa) {
			dis[e.to] = dis[u] + e.w;
			dfs(e.to, u);
			sq[u] += sq[e.to];
		}
}

double ans = 1e100;
int anspos;
void divi(int s, int n) {
	csize = 1000000000;
	get(s, n);
	int u = cen;
	// debug("divi %d get %d\n", s, u);

	dis[u] = 0;
	sum = 0;
	dfs(u, 0);
	if(sum < ans) {
		ans = sum;
		anspos = u;
	}

	// debug("%d : %.5lf\n", u, sq[u]);
	// for(Edge e : G[u])
		// if(!vis[e.to])
			// debug("%d : %.5lf\n", e.to, sq[e.to]);

	int to = 0;
	for(Edge e : G[u])
		if(!vis[e.to] and sq[u] - sq[e.to] * 2 < 0)
			to = e.to;
	if(!to) return;

	vis[u] = 1;
	if(size[to] < size[u])
		divi(to, size[to]);
	else
		divi(to, n - size[u]);
}

int main() {
	int n = read;
	for(int i = 1; i <= n; i ++)
		val[i] = read;

	for(int i = 1; i < n; i ++) {
		int u = read, v = read, w = read;
		G[u].push_back({v, w});
		G[v].push_back({u, w});
	}

	divi(1, n);
	printf("%d %.7lf\n", anspos, ans);
}


#if 0
date

流皮流皮
#endif
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
} read;

const int maxn = 200005;
// int head[maxn], nxt[maxn << 1], to[maxn << 1], len[maxn << 1], hp = 1;
struct Edge {
	int to, w;
};
std::vector<Edge> G[maxn];
int val[maxn];

bool vis[maxn];
int size[maxn];
int cen, csize;
void get(int u, int n) {
	size[u] = 1;
	int now = 0;
	vis[u] = 1;
	for(Edge e : G[u])
		if(!vis[e.to]) {
			get(e.to, n);
			size[u] += size[e.to];
			now = std::max(now, size[e.to]);
		}
	vis[u] = 0;
	now = std::max(now, n - size[u]);
	if(now < csize) {
		cen = u;
		csize = now;
	}
}

int dis[maxn];
double sq[maxn], sum;
void dfs(int u, int fa) {
	sq[u] = sqrt(dis[u]) * val[u];
	sum += sq[u] * dis[u];
	for(Edge e : G[u])
		if(e.to != fa) {
			dis[e.to] = dis[u] + e.w;
			dfs(e.to, u);
			sq[u] += sq[e.to];
		}
}

double ans = 1e100;
int anspos;
void divi(int s, int n) {
	csize = 1000000000;
	get(s, n);
	int u = cen;
	// debug("divi %d get %d\n", s, u);

	dis[u] = 0;
	sum = 0;
	dfs(u, 0);
	if(sum < ans) {
		ans = sum;
		anspos = u;
	}

	// debug("%d : %.5lf\n", u, sq[u]);
	// for(Edge e : G[u])
		// if(!vis[e.to])
			// debug("%d : %.5lf\n", e.to, sq[e.to]);

	int to = 0;
	for(Edge e : G[u])
		if(!vis[e.to] and sq[u] - sq[e.to] * 2 < 0)
			to = e.to;
	if(!to) return;

	vis[u] = 1;
	if(size[to] < size[u])
		divi(to, size[to]);
	else
		divi(to, n - size[u]);
}

int main() {
	int n = read;
	for(int i = 1; i <= n; i ++)
		val[i] = read;

	for(int i = 1; i < n; i ++) {
		int u = read, v = read, w = read;
		G[u].push_back({v, w});
		G[v].push_back({u, w});
	}

	divi(1, n);
	printf("%d %.7lf\n", anspos, ans);
}


#if 0
date
#endif
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
} read;

const int maxn = 400005;
// int head[maxn], nxt[maxn << 1], to[maxn << 1], len[maxn << 1], hp = 1;
struct Edge {
	int to, w;
};
std::vector<Edge> G[maxn];
int val[maxn];

int bel[maxn], last[maxn], np;
void expand(int u) {
	if(last[u]) {
		bel[++ np] = u;
		// add(last[u], np, 0);
		// add(np, last[u], 0);
		G[last[u]].push_back({np, 0});
		G[np].push_back({last[u], 0});
		// debug("%d %d\n", last[u], np);
		last[u] = np;
	} else
		last[u] = u;
}

int N;
double f[maxn];
int dis[maxn];
void get(int u, int fa) {
	for(Edge e : G[u])
		if(e.to != fa) {
			dis[e.to] = dis[u] + e.w;
			get(e.to, u);
		}
}

double F(int s) {
	if(f[s] > 0) return f[s];
	dis[s] = 0;
	get(s, 0);
	f[s] = 0;
	for(int u = 1; u <= N; u ++)
		f[s] += dis[u] * sqrt(dis[u]) * val[u];
	return f[s];
}

bool vis[maxn];
int size[maxn];
int fa[maxn];
int cen;
void dfs(int u, int n) {
	vis[u] = 1;
	size[u] = 1;
	for(Edge e : G[u])
		if(!vis[e.to]) {
			fa[e.to] = u;
			dfs(e.to, n);
			size[u] += size[e.to];
		}
	vis[u] = 0;
	if(std::max(size[u], n - size[u]) <= std::max(size[cen], n - size[cen]))
		cen = u;
}

void divi(int s, int n) {
	if(n == 1) {
		printf("%d %.7lf\n", bel[s], F(s));
		return;
	}

	cen = s;
	dfs(s, n);

	int a = fa[cen], b = cen;
	if(F(a) < F(b)) {
		vis[b] = 1;
		divi(a, n - size[b]);
	} else {
		vis[a] = 1;
		divi(b, size[b]);
	}
}

int main() {
	int n = N = read;
	for(int i = 1; i <= n; i ++)
		val[i] = read;

	np = n;
	for(int i = 1; i < n; i ++) {
		int u = read, v = read, w = read;
		expand(u);
		expand(v);
		G[last[u]].push_back({last[v], w});
		G[last[v]].push_back({last[u], w});
		// debug("%d %d\n", last[u], last[v]);
	}

	divi(1, n);
}


#if 0
date
#endif
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
} read;

const int maxn = 400005;
// int head[maxn], nxt[maxn << 1], to[maxn << 1], len[maxn << 1], hp = 1;
struct Edge {
	int to, w;
};
std::vector<Edge> G[maxn];
int val[maxn];

int bel[maxn], last[maxn], np;
void expand(int u) {
	if(last[u]) {
		bel[++ np] = u;
		// add(last[u], np, 0);
		// add(np, last[u], 0);
		G[last[u]].push_back({np, 0});
		G[np].push_back({last[u], 0});
		// debug("%d %d\n", last[u], np);
		last[u] = np;
	} else
		last[u] = u;
}

int N;
double f[maxn];
int dis[maxn];
void get(int u, int fa) {
	for(Edge e : G[u])
		if(e.to != fa) {
			dis[e.to] = dis[u] + e.w;
			get(e.to, u);
		}
}

double F(int s) {
	if(f[s] > 0) return f[s];
	dis[s] = 0;
	get(s, 0);
	f[s] = 0;
	for(int u = 1; u <= N; u ++)
		f[s] += dis[u] * sqrt(dis[u]) * val[u];
	return f[s];
}

bool vis[maxn];
int size[maxn];
int fa[maxn];
int cen;
void dfs(int u, int n) {
	vis[u] = 1;
	size[u] = 1;
	for(Edge e : G[u])
		if(!vis[e.to]) {
			fa[e.to] = u;
			dfs(e.to, n);
			size[u] += size[e.to];
		}
	vis[u] = 0;
	if(std::max(size[u], n - size[u]) <= std::max(size[cen], n - size[cen]))
		cen = u;
}

void divi(int s, int n) {
	if(n == 1) {
		printf("%d %.7lf\n", bel[s], F(s));
		return;
	}

	cen = s;
	dfs(s, n);

	int a = fa[cen], b = cen;
	if(F(a) < F(b)) {
		vis[b] = 1;
		divi(a, n - size[b]);
	} else {
		vis[a] = 1;
		divi(b, size[b]);
	}
}

int main() {
	int n = N = read;
	for(int i = 1; i <= n; i ++)
		val[i] = read;

	for(int i = 1; i <= n; i ++)
		bel[i] = i;

	np = n;
	for(int i = 1; i < n; i ++) {
		int u = read, v = read, w = read;
		expand(u);
		expand(v);
		G[last[u]].push_back({last[v], w});
		G[last[v]].push_back({last[u], w});
		// debug("%d %d\n", last[u], last[v]);
	}

	divi(1, n);
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define ll long long
#define M 1000000007
#define all(a) a.begin(), a.end()

const int maxn = 200100;
int n, m, rt;
long double res;
pair<long double, int> ans;
int w[maxn], sz[maxn];
long double dev[maxn];
vector<pair<int, int>> ed[maxn];
bool del[maxn];

void findroot(int t, int fa){
	sz[t] = 1;
	int tmax = 0;
	for(auto e : ed[t]){
		int v = e.fi;
		if(v == fa || del[v]) continue;
		findroot(v, t);
		sz[t] += sz[v];
		tmax = max(sz[v], tmax);
	}
	tmax = max(m - sz[t], tmax);
	if(tmax <= m / 2) rt = t;
}

void dfs(int t, int fa, int ce, ll d){
	sz[t] = 1;
	if(!ce && fa) ce = t, dev[t] = 0;
	dev[ce] += sqrt(d) * w[t];
	res += d * sqrt(d) * w[t];
	for(auto e : ed[t]){
		int v = e.fi, c = e.se;
		if(v == fa) continue;
		dfs(v, t, ce, d + c);
		sz[t] += sz[v];
	}
}

void solve(int t){
	findroot(t, 0);
	res = 0;
	dfs(rt, 0, 0, 0);
	del[rt] = 1;
	ans = min(ans, mkp(res, rt));
	long double sum = 0;
	for(auto e : ed[rt]){
		int v = e.fi;
		sum += dev[v];
	}
	int nex = 0;
	for(auto e : ed[rt]){
		int v = e.fi;
		if(del[v]) continue;
		if(sum - 2 * dev[v] < 0) nex = v;
	}
	if(nex) m = sz[nex], solve(nex);
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", w + i);
	for(int i = 1; i < n; ++i){
		static int u, v, c;
		scanf("%d%d%d", &u, &v, &c);
		ed[u].pb(mkp(v, c));
		ed[v].pb(mkp(u, c));
	}
	m = n;
	ans = mkp(1e100, 0);
	solve(1);
	printf("%d %.10f\n", ans.se, (double)ans.fi);

#ifndef ONLINE_JUDGE
	system("pause");
#endif
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define ll long long
#define M 1000000007
#define all(a) a.begin(), a.end()

const int maxn = 200100;
int n, m, rt;
long double res;
pair<long double, int> ans;
int w[maxn], sz[maxn];
long double dev[maxn];
vector<pair<int, int>> ed[maxn];
bool del[maxn];

void findroot(int t, int fa){
	sz[t] = 1;
	int tmax = 0;
	for(auto e : ed[t]){
		int v = e.fi;
		if(v == fa || del[v]) continue;
		findroot(v, t);
		sz[t] += sz[v];
		tmax = max(sz[v], tmax);
	}
	tmax = max(m - sz[t], tmax);
	if(tmax <= m / 2) rt = t;
}

void dfs(int t, int fa, int ce, ll d){
	sz[t] = 1;
	if(!ce && !fa) ce = t, dev[t] = 0;
	dev[ce] += sqrt(d) * w[t];
	res += d * sqrt(d) * w[t];
	for(auto e : ed[t]){
		int v = e.fi, c = e.se;
		if(v == fa) continue;
		dfs(v, t, ce, d + c);
		sz[t] += sz[v];
	}
}

void solve(int t){
	findroot(t, 0);
	res = 0;
	dfs(rt, 0, 0, 0);
	del[rt] = 1;
	ans = min(ans, mkp(res, rt));
	long double sum = 0;
	for(auto e : ed[rt]){
		int v = e.fi;
		sum += dev[v];
	}
	int nex = 0;
	for(auto e : ed[rt]){
		int v = e.fi;
		if(del[v]) continue;
		if(sum - 2 * dev[v] < 0) nex = v;
	}
	if(nex) m = sz[nex], solve(nex);
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", w + i);
	for(int i = 1; i < n; ++i){
		static int u, v, c;
		scanf("%d%d%d", &u, &v, &c);
		ed[u].pb(mkp(v, c));
		ed[v].pb(mkp(u, c));
	}
	m = n;
	ans = mkp(1e100, 0);
	solve(1);
	printf("%d %.10f\n", ans.se, (double)ans.fi);

#ifndef ONLINE_JUDGE
	system("pause");
#endif
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define ll long long
#define M 1000000007
#define all(a) a.begin(), a.end()

const int maxn = 200100;
int n, m, rt;
long double res;
pair<long double, int> ans;
int w[maxn], sz[maxn];
long double dev[maxn];
vector<pair<int, int>> ed[maxn];
bool del[maxn];

void dfs(int t, int fa){
	sz[t] = 1;
	for(auto e : ed[t]){
		int v = e.fi;
		if(v == fa || del[v]) continue;
		dfs(v, t);
		sz[t] += sz[v];
	}
}

void getroot(int t, int fa){
	int tmax = 0;
	for(auto e : ed[t]){
		int v = e.fi;
		if(v == fa || del[v]) continue;
		getroot(v, t);
		tmax = max(tmax, sz[v]);
	}
	tmax = max(m - sz[t], tmax);
	if(tmax <= m / 2) rt = t;
}

void dfs(int t, int fa, int ce, ll d){
	if(!ce && fa) ce = t, dev[t] = 0;
	dev[ce] += sqrt(d) * w[t];
	res += d * sqrt(d) * w[t];
	for(auto e : ed[t]){
		int v = e.fi, c = e.se;
		if(v == fa) continue;
		dfs(v, t, ce, d + c);
	}
}

void solve(int t){
	dfs(t, 0);
	m = sz[t];
	getroot(t, 0);

	res = 0;
	dfs(rt, 0, 0, 0);
	del[rt] = 1;
	ans = min(ans, mkp(res, rt));
	long double sum = 0;
	for(auto e : ed[rt]){
		int v = e.fi;
		sum += dev[v];
	}
	int nex = 0;
	for(auto e : ed[rt]){
		int v = e.fi;
		if(del[v]) continue;
		if(sum - 2 * dev[v] < 0) nex = v;
	}
	if(nex) solve(nex);
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", w + i);
	for(int i = 1; i < n; ++i){
		static int u, v, c;
		scanf("%d%d%d", &u, &v, &c);
		ed[u].pb(mkp(v, c));
		ed[v].pb(mkp(u, c));
	}
	ans = mkp(1e100, 0);
	solve(1);
	printf("%d %.10f\n", ans.se, (double)ans.fi);

#ifndef ONLINE_JUDGE
	system("pause");
#endif
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define _N 200001

struct Side
{
    int to;
    int next;
    int length;
    Side()
    {
        to = next = length = 0;
    }
    Side(int a, int b, int c)
    {
        to = a;
        length = b;
        next = c;
    }
};

int n;

int w[_N];

int sidecnt;
int head[_N];
Side sides[_N << 1];

bool visited[_N];
int siz[_N];
int maxpart[_N] = { 0x3f3f3f3f };

double d[_N];
double v[_N];
int ans1;
double ans2 = 1e20;

void inline adde(int x, int y, int z, bool repeat = true)
{
    sides[++sidecnt] = Side(y, z, head[x]);
    head[x] = sidecnt;
    if (repeat)
    {
        adde(y, x, z, false);
    }
}

int center(int x, int father, int sum)
{
    int rt = 0;
    siz[x] = 1;
    maxpart[x] = 0;
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            int subc = center(y, x, sum);
            maxpart[x] = std::max(maxpart[x], siz[y]);
            siz[x] += siz[y];
            if (maxpart[subc] < maxpart[rt])
            {
                rt = subc;
            }
        }
        next = sides[next].next;
    }
    maxpart[x] = std::max(maxpart[x], sum - siz[x]);
    if (maxpart[x] < maxpart[rt])
    {
        rt = x;
    }
    return rt;
}

void dfs1(int x, int father, double& sum, int dis)
{
    sum += std::pow(dis, 1.5) * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father)
        {
            dfs1(y, x, sum, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void dfs2(int x, int father, double& sum1, int dis)
{
    sum1 += std::pow(dis, 0.5) * 1.5 * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father)
        {
            dfs2(y, x, sum1, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void calc(int x)
{
    visited[x] = true;
    v[x] = 0;
    dfs1(x, 0, v[x], 0);
    if (v[x] < ans2)
    {
        ans1 = x;
        ans2 = v[x];
    }
    int next = head[x];
    double dsum = 0;
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            d[y] = 0;
            dfs2(y, 0, d[y], sides[next].length);
            dsum += d[y];
        }
        next = sides[next].next;
    }
    next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            if (dsum - d[y] * 2 < 0)
            {
                calc(center(y, x, siz[y]));
                break;
            }
        }
        next = sides[next].next;
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &w[i]);
    }
    for (int i = 1; i < n; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        adde(x, y, z);
    }
    calc(center(1, 0, n));
    printf("%d %.10lf", ans1, ans2);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define _N 200001

struct Side
{
    int to;
    int next;
    int length;
    Side()
    {
        to = next = length = 0;
    }
    Side(int a, int b, int c)
    {
        to = a;
        length = b;
        next = c;
    }
};

int n;

int w[_N];

int sidecnt;
int head[_N];
Side sides[_N << 1];

bool visited[_N];
int siz[_N];
int maxpart[_N] = { 0x3f3f3f3f };

double d[_N];
double v[_N];
int ans1;
double ans2 = 1e20;

void inline adde(int x, int y, int z, bool repeat = true)
{
    sides[++sidecnt] = Side(y, z, head[x]);
    head[x] = sidecnt;
    if (repeat)
    {
        adde(y, x, z, false);
    }
}

int center(int x, int father, int sum)
{
    int rt = 0;
    siz[x] = 1;
    maxpart[x] = 0;
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            int subc = center(y, x, sum);
            maxpart[x] = std::max(maxpart[x], siz[y]);
            siz[x] += siz[y];
            if (maxpart[subc] < maxpart[rt])
            {
                rt = subc;
            }
        }
        next = sides[next].next;
    }
    maxpart[x] = std::max(maxpart[x], sum - siz[x]);
    if (maxpart[x] < maxpart[rt])
    {
        rt = x;
    }
    return rt;
}

void dfs1(int x, int father, double& sum, int dis)
{
    sum += std::pow(dis, 1.5) * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father)
        {
            dfs1(y, x, sum, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void dfs2(int x, int father, double& sum1, int dis)
{
    sum1 += std::pow(dis, 0.5) * 1.5 * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father)
        {
            dfs2(y, x, sum1, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void calc(int x)
{
    visited[x] = true;
    v[x] = 0;
    dfs1(x, 0, v[x], 0);
    if (v[x] < ans2)
    {
        ans1 = x;
        ans2 = v[x];
    }
    int next = head[x];
    double dsum = 0;
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            d[y] = 0;
            dfs2(y, x, d[y], sides[next].length);
            dsum += d[y];
        }
        next = sides[next].next;
    }
    next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            if (dsum - d[y] * 2 < 0)
            {
                calc(center(y, x, siz[y]));
                break;
            }
        }
        next = sides[next].next;
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &w[i]);
    }
    for (int i = 1; i < n; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        adde(x, y, z);
    }
    calc(center(1, 0, n));
    printf("%d %.10lf", ans1, ans2);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define _N 200001

struct Side
{
    int to;
    int next;
    int length;
    Side()
    {
        to = next = length = 0;
    }
    Side(int a, int b, int c)
    {
        to = a;
        length = b;
        next = c;
    }
};

int n;

int w[_N];

int sidecnt;
int head[_N];
Side sides[_N << 1];

bool visited[_N];
int siz[_N];
int maxpart[_N] = { 0x3f3f3f3f };

double d[_N];
double v[_N];
int ans1;
double ans2 = 1e20;

void inline adde(int x, int y, int z, bool repeat = true)
{
    sides[++sidecnt] = Side(y, z, head[x]);
    head[x] = sidecnt;
    if (repeat)
    {
        adde(y, x, z, false);
    }
}

int center(int x, int father, int sum)
{
    int rt = 0;
    siz[x] = 1;
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            int subc = center(y, x, sum);
            maxpart[x] = std::max(maxpart[x], siz[y]);
            siz[x] += siz[y];
            if (maxpart[subc] < maxpart[rt])
            {
                rt = subc;
            }
        }
        next = sides[next].next;
    }
    maxpart[x] = std::max(maxpart[x], sum - siz[x]);
    if (maxpart[x] < maxpart[rt])
    {
        rt = x;
    }
    return rt;
}

void dfs1(int x, int father, double& sum, int dis)
{
    sum += std::pow(dis, 1.5) * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father)
        {
            dfs1(y, x, sum, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void dfs2(int x, int father, double& sum1, int dis)
{
    sum1 += std::pow(dis, 0.5) * 1.5 * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            dfs2(y, x, sum1, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void calc(int x)
{
    visited[x] = true;
    v[x] = 0;
    dfs1(x, 0, v[x], 0);
    if (v[x] < ans2)
    {
        ans1 = x;
        ans2 = v[x];
    }
    int next = head[x];
    double dsum = 0;
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            d[y] = 0;
            dfs2(y, 0, d[y], sides[next].length);
            dsum += d[y];
        }
        next = sides[next].next;
    }
    next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            if (dsum - d[y] * 2 < 0)
            {
                calc(center(y, x, siz[y]));
                break;
            }
        }
        next = sides[next].next;
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &w[i]);
    }
    for (int i = 1; i < n; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        adde(x, y, z);
    }
    calc(center(1, 0, n));
    printf("%d %.10lf", ans1, ans2);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define _N 200001

struct Side
{
    int to;
    int next;
    int length;
    Side()
    {
        to = next = length = 0;
    }
    Side(int a, int b, int c)
    {
        to = a;
        length = b;
        next = c;
    }
};

int n;

int w[_N];

int sidecnt;
int head[_N];
Side sides[_N << 1];

bool visited[_N];
int siz[_N];
int maxpart[_N] = { 0x3f3f3f3f };

double d[_N];
double v[_N];
int ans1;
double ans2 = 1e20;

void inline adde(int x, int y, int z, bool repeat = true)
{
    sides[++sidecnt] = Side(y, z, head[x]);
    head[x] = sidecnt;
    if (repeat)
    {
        adde(y, x, z, false);
    }
}

int center(int x, int father, int sum)
{
    int rt = 0;
    siz[x] = 1;
    maxpart[x] = 0;
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            int subc = center(y, x, sum);
            maxpart[x] = std::max(maxpart[x], siz[y]);
            siz[x] += siz[y];
            if (maxpart[subc] < maxpart[rt])
            {
                rt = subc;
            }
        }
        next = sides[next].next;
    }
    maxpart[x] = std::max(maxpart[x], sum - siz[x]);
    if (maxpart[x] < maxpart[rt])
    {
        rt = x;
    }
    return rt;
}

void dfs1(int x, int father, double& sum, int dis)
{
    sum += std::pow(dis, 1.5) * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father)
        {
            dfs1(y, x, sum, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void dfs2(int x, int father, double& sum1, int dis)
{
    sum1 += std::pow(dis, 0.5) * 1.5 * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            dfs2(y, x, sum1, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void calc(int x)
{
    visited[x] = true;
    v[x] = 0;
    dfs1(x, 0, v[x], 0);
    if (v[x] < ans2)
    {
        ans1 = x;
        ans2 = v[x];
    }
    int next = head[x];
    double dsum = 0;
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            d[y] = 0;
            dfs2(y, 0, d[y], sides[next].length);
            dsum += d[y];
        }
        next = sides[next].next;
    }
    next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            if (dsum - d[y] * 2 < 0)
            {
                calc(center(y, x, siz[y]));
                break;
            }
        }
        next = sides[next].next;
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &w[i]);
    }
    for (int i = 1; i < n; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        adde(x, y, z);
    }
    calc(center(1, 0, n));
    printf("%d %.10lf", ans1, ans2);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define _N 200001

struct Side
{
    int to;
    int next;
    int length;
    Side()
    {
        to = next = length = 0;
    }
    Side(int a, int b, int c)
    {
        to = a;
        length = b;
        next = c;
    }
};

int n;

int w[_N];

int sidecnt;
int head[_N];
Side sides[_N << 1];

bool visited[_N];
int siz[_N];
int maxpart[_N] = { 0x3f3f3f3f };

double d[_N];
double v[_N];
int ans1;
double ans2 = 1e20;

void inline adde(int x, int y, int z, bool repeat = true)
{
    sides[++sidecnt] = Side(y, z, head[x]);
    head[x] = sidecnt;
    if (repeat)
    {
        adde(y, x, z, false);
    }
}

int center(int x, int father, int sum)
{
    int rt = 0;
    siz[x] = 1;
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            int subc = center(y, x, sum);
            maxpart[x] = std::max(maxpart[x], siz[y]);
            siz[x] += siz[y];
            if (maxpart[subc] < maxpart[rt])
            {
                rt = subc;
            }
        }
        next = sides[next].next;
    }
    maxpart[x] = std::max(maxpart[x], sum - siz[x]);
    if (maxpart[x] < maxpart[rt])
    {
        rt = x;
    }
    return rt;
}

void dfs1(int x, int father, double& sum, int dis)
{
    sum += std::pow(dis, 1.5) * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father)
        {
            dfs1(y, x, sum, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void dfs2(int x, int father, double& sum, int dis)
{
    sum += std::pow(dis, 0.5) * 1.5 * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            dfs2(y, x, sum, sides[next].length);
        }
        next = sides[next].next;
    }
}

void calc(int x)
{
    visited[x] = true;
    v[x] = 0;
    dfs1(x, 0, v[x], 0);
    if (v[x] < ans2)
    {
        ans1 = x;
        ans2 = v[x];
    }
    int next = head[x];
    double dsum = 0;
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            d[y] = 0;
            dfs2(y, 0, d[y], sides[next].length);
            dsum += d[y];
        }
        next = sides[next].next;
    }
    next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            if (dsum - d[y] * 2 < 0)
            {
                calc(y);
                break;
            }
        }
        next = sides[next].next;
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &w[i]);
    }
    for (int i = 1; i < n; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        adde(x, y, z);
    }
    calc(center(1, 0, n));
    printf("%d %lf", ans1, ans2);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define _N 200001

struct Side
{
    int to;
    int next;
    int length;
    Side()
    {
        to = next = length = 0;
    }
    Side(int a, int b, int c)
    {
        to = a;
        length = b;
        next = c;
    }
};

int n;

int w[_N];

int sidecnt;
int head[_N];
Side sides[_N << 1];

bool visited[_N];
int siz[_N];
int maxpart[_N] = { 0x3f3f3f3f };

double d[_N];
double v[_N];
int ans1;
double ans2 = 1e20;

void inline adde(int x, int y, int z, bool repeat = true)
{
    sides[++sidecnt] = Side(y, z, head[x]);
    head[x] = sidecnt;
    if (repeat)
    {
        adde(y, x, z, false);
    }
}

int center(int x, int father, int sum)
{
    int rt = 0;
    siz[x] = 1;
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            int subc = center(y, x, sum);
            maxpart[x] = std::max(maxpart[x], siz[y]);
            siz[x] += siz[y];
            if (maxpart[subc] < maxpart[rt])
            {
                rt = subc;
            }
        }
        next = sides[next].next;
    }
    maxpart[x] = std::max(maxpart[x], sum - siz[x]);
    if (maxpart[x] < maxpart[rt])
    {
        rt = x;
    }
    return rt;
}

void dfs1(int x, int father, double& sum, int dis)
{
    sum += std::pow(dis, 1.5) * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father)
        {
            dfs1(y, x, sum, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void dfs2(int x, int father, double& sum, int dis)
{
    sum += std::pow(dis, 0.5) * 1.5 * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            dfs2(y, x, sum, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void calc(int x)
{
    visited[x] = true;
    v[x] = 0;
    dfs1(x, 0, v[x], 0);
    if (v[x] < ans2)
    {
        ans1 = x;
        ans2 = v[x];
    }
    int next = head[x];
    double dsum = 0;
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            d[y] = 0;
            dfs2(y, 0, d[y], sides[next].length);
            dsum += d[y];
        }
        next = sides[next].next;
    }
    next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            if (dsum - d[y] * 2 < 0)
            {
                calc(y);
                break;
            }
        }
        next = sides[next].next;
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &w[i]);
    }
    for (int i = 1; i < n; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        adde(x, y, z);
    }
    calc(center(1, 0, n));
    printf("%d %.10lf", ans1, ans2);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define _N 200001

struct Side
{
    int to;
    int next;
    int length;
    Side()
    {
        to = next = length = 0;
    }
    Side(int a, int b, int c)
    {
        to = a;
        length = b;
        next = c;
    }
};

int n;

int w[_N];

int sidecnt;
int head[_N];
Side sides[_N << 1];

bool visited[_N];
int siz[_N];
int maxpart[_N] = { 0x3f3f3f3f };

double d[_N];
double v[_N];
int ans1;
double ans2 = 1e20;

void inline adde(int x, int y, int z, bool repeat = true)
{
    sides[++sidecnt] = Side(y, z, head[x]);
    head[x] = sidecnt;
    if (repeat)
    {
        adde(y, x, z, false);
    }
}

int center(int x, int father, int sum)
{
    int rt = 0;
    siz[x] = 1;
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            int subc = center(y, x, sum);
            maxpart[x] = std::max(maxpart[x], siz[y]);
            siz[x] += siz[y];
            if (maxpart[subc] < maxpart[rt])
            {
                rt = subc;
            }
        }
        next = sides[next].next;
    }
    maxpart[x] = std::max(maxpart[x], sum - siz[x]);
    if (maxpart[x] < maxpart[rt])
    {
        rt = x;
    }
    return rt;
}

void dfs1(int x, int father, double& sum, int dis)
{
    sum += std::pow(dis, 1.5) * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father)
        {
            dfs1(y, x, sum, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void dfs2(int x, int father, double& sum, int dis)
{
    sum += std::pow(dis, 0.5) * 1.5 * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            dfs2(y, x, sum, sides[next].length);
        }
        next = sides[next].next;
    }
}

void calc(int x)
{
    visited[x] = true;
    v[x] = 0;
    dfs1(x, 0, v[x], 0);
    if (v[x] < ans2)
    {
        ans1 = x;
        ans2 = v[x];
    }
    int next = head[x];
    double dsum = 0;
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            d[y] = 0;
            dfs2(y, 0, d[y], sides[next].length);
            dsum += d[y];
        }
        next = sides[next].next;
    }
    next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            if (dsum - d[y] * 2 < 0)
            {
                calc(y);
                break;
            }
        }
        next = sides[next].next;
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &w[i]);
    }
    for (int i = 1; i < n; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        adde(x, y, z);
    }
    calc(center(1, 0, n));
    printf("%d %.10lf", ans1, ans2);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define _N 200001

struct Side
{
    int to;
    int next;
    int length;
    Side()
    {
        to = next = length = 0;
    }
    Side(int a, int b, int c)
    {
        to = a;
        length = b;
        next = c;
    }
};

int n;

int w[_N];

int sidecnt;
int head[_N];
Side sides[_N << 1];

bool visited[_N];
int siz[_N];
int maxpart[_N] = { 0x3f3f3f3f };

double d[_N];
double v[_N];
int ans1;
double ans2 = 1e20;

void inline adde(int x, int y, int z, bool repeat = true)
{
    sides[++sidecnt] = Side(y, z, head[x]);
    head[x] = sidecnt;
    if (repeat)
    {
        adde(y, x, z, false);
    }
}

int center(int x, int father, int sum)
{
    int rt = 0;
    siz[x] = 1;
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            int subc = center(y, x, sum);
            maxpart[x] = std::max(maxpart[x], siz[y]);
            siz[x] += siz[y];
            if (maxpart[subc] < maxpart[rt])
            {
                rt = subc;
            }
        }
        next = sides[next].next;
    }
    maxpart[x] = std::max(maxpart[x], sum - siz[x]);
    if (maxpart[x] < maxpart[rt])
    {
        rt = x;
    }
    return rt;
}

void dfs1(int x, int father, double& sum, int dis)
{
    sum += std::pow(dis, 1.5) * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father)
        {
            dfs1(y, x, sum, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void dfs2(int x, int father, double& sum, int dis)
{
    sum += std::pow(dis, 0.5) * 1.5 * w[x];
    int next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (y != father && !visited[y])
        {
            dfs2(y, x, sum, dis + sides[next].length);
        }
        next = sides[next].next;
    }
}

void calc(int x)
{
    visited[x] = true;
    v[x] = 0;
    dfs1(x, 0, v[x], 0);
    if (v[x] < ans2)
    {
        ans1 = x;
        ans2 = v[x];
    }
    int next = head[x];
    double dsum = 0;
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            d[y] = 0;
            dfs2(y, 0, d[y], sides[next].length);
            dsum += d[y];
        }
        next = sides[next].next;
    }
    next = head[x];
    while (next != 0)
    {
        int y = sides[next].to;
        if (!visited[y])
        {
            if (dsum - d[y] * 2 < 0)
            {
                calc(center(y, x, siz[y]));
                break;
            }
        }
        next = sides[next].next;
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &w[i]);
    }
    for (int i = 1; i < n; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        adde(x, y, z);
    }
    calc(center(1, 0, n));
    printf("%d %.10lf", ans1, ans2);
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#define eps 0.000001
using namespace std;
int n;
double w[(int)2e5+5];
int h[(int)2e5+5], tot;
int ans1;
double ans2;
struct edge {
	int to, nxt;
	double val;
} e[(int)4e5+5];

void add (int x, int y, double z) {
	e[++tot] = (edge) { y, h[x], z };
	h[x] = tot;
}

double deal (int k, double far, int fa) {
	double ans = 0.0;
	for (int u = h[k]; u; u = e[u].nxt)
		if (e[u].to != fa) ans += deal (e[u].to, far + e[u].val, k);
	return ans + w[k] * far * sqrt(far) * 1.0;
}

const bool cmp_double (double t1, double t2) {
	if (t1 >= t2 - eps && t1 <= t2 + eps) return 1;
	return 0;
}

int main() {
	int i,j,k;
	int x, y;
	double z;
	long long MAXN = (1ll<<62) - 1;
	ans2 = MAXN;
	scanf ("%d", &n);
	for (i=1; i<=n; ++i) scanf ("%lf", &w[i]);
	for (i=1; i<n; ++i) {
		scanf ("%d%d%lf", &x, &y, &z);
		add (x, y, z), add (y, x, z);
	}
	for (i=1; i<=n; ++i) {
		z = deal (i, 0.0, i);
		if (cmp_double (ans2, z)) continue;
		if (z < ans2) ans1 = i, ans2 = z;
	}
	printf ("%d %.16lf\n", ans1, ans2);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
namespace red{
#define int long long
#define ls(p) (p<<1)
#define rs(p) (p<<1|1)
#define mid ((l+r)>>1)
	inline int read()
	{
		int x=0;char ch,f=1;
		for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar());
		if(ch=='-') f=0,ch=getchar();
		while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
		return f?x:-x;
	}
	const int N=4e5+10;
	int n;
	int v[N];
	int head[N],cnt;
	struct point
	{
		int nxt,to,val;
		point(){}
		point(const int &nxt,const int &to,const int &val):nxt(nxt),to(to),val(val){}
	}a[N<<1];
	inline void link(int x,int y,int z)
	{
		a[++cnt]=(point){head[x],y,z};head[x]=cnt;
		a[++cnt]=(point){head[y],x,z};head[y]=cnt;
	}
	int str[N],mx[N],rt,all;
	double sum,sumd,ans2=1e100,dis[N];
	int ans1;
	bool vis[N];
	inline void find(int now,int fa)
	{
		str[now]=1,mx[now]=0;
		for(int i=head[now];i;i=a[i].nxt)
		{
			int t=a[i].to;
			if(t==fa||vis[t]) continue;
			find(t,now);
			str[now]+=str[t];
			mx[now]=max(mx[now],str[t]);
		}
		mx[now]=max(mx[now],all-str[now]);
		if(mx[now]<mx[rt]) rt=now;
	}
	inline void calc(int x,int y,int fa,double dep)
	{
		sum+=1.0*dep*sqrt(dep)*v[x],sumd+=1.0*v[x]*sqrt(dep)*3/2;
		dis[y]+=1.0*v[x]*sqrt(dep)*3/2;
		for(int i=head[x];i;i=a[i].nxt)
		{
			int t=a[i].to;
			if(t==fa) continue;
			calc(t,y,x,dep+a[i].val);
		}
	}
	inline void divide(int now)
	{
		if(vis[now]) return;
		vis[now]=1;
		sum=0,sumd=0;
		for(int i=head[now];i;i=a[i].nxt)
		{
			int t=a[i].to;
			dis[t]=0;calc(t,t,now,a[i].val);
		}
		if(sum<ans2) ans2=sum,ans1=now;
		for(int i=head[now];i;i=a[i].nxt)
		{
			int t=a[i].to;
			if(sumd-dis[t]*2>=0) continue;
			if(vis[t]) continue;
			rt=0,all=str[t];
			find(t,0);
			divide(rt);
		}
	}
	inline void main()
	{
		n=read();
		for(int i=1;i<=n;++i) v[i]=read();
		for(int x,y,i=1;i<n;++i)
		{
			x=read(),y=read();
			link(x,y,read());
		}
		rt=0,mx[0]=all=n;
		find(1,0);
		divide(rt);
		printf("%lld %.10lf",ans1,ans2);
	}
}
signed main()
{
	red::main();
	return 0;
}


// No.094821032420
#include <bits/stdc++.h>
#define N 200200
using namespace std;
typedef long long ll;
const double eps = 1e-12;

inline int sgn(double x) {
    return fabs(x) < eps ? 0 : (x < 0 ? -1 : 1);
}

int n, d[N];
int tot = 1, fir[N], nxt[N << 1], to[N << 1], val[N << 1];

inline void addE(int u, int v, int w) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v, val[tot] = w;
}

int vis[N], sz[N];

void getrt(int u, int p, int z, int &rt, int &rs) {
    int tmp = 0; sz[u] = 1;
    for (int i = fir[u], v; i; i = nxt[i]) {
        v = to[i];
        if (v == p || vis[v]) continue;
        getrt(v, u, z, rt, rs);
        tmp = max(tmp, sz[v]);
        sz[u] += sz[v];
    } tmp = max(tmp, z - sz[u]);
    if (tmp < rs) rs = tmp, rt = u;
}

double dip[N];

double calc(int u, int p, int dis) {
    double sum = 0; dip[u] = 0;
    for (int i = fir[u], v; i; i = nxt[i]) {
        v = to[i];
        if (v == p) continue;
        sum += calc(v, u, dis + val[i]);
        dip[u] += dip[v];
    }
    dip[u] += sqrt(dis) * d[u];
    return sum + sqrt(dis) * dis * d[u];
}

double ans = 1e30;
int dans;

void solve(int u, int z) {
    int rt, rs = n;
    getrt(u, 0, z, rt, rs);
    // cout << u << " " << rt << " " << rs << endl;
    u = rt, vis[u] = 1;
    double sum = 0, sump = 0;
    for (int i = fir[u], v; i; i = nxt[i]) {
        v = to[i];
        sum += calc(v, u, val[i]);
        sump += dip[v];
    }
    if (sgn(ans - sum) > 0) ans = sum, dans = u;
    double now = 1e18; int go = 0;
    for (int i = fir[u], v; i; i = nxt[i]) {
        v = to[i];
        if (vis[v]) continue;
        if (sgn(now - (sum - dip[v] - dip[v])) > 0)
            now = (sum - dip[v] - dip[v]), go = v;
    }
    if (go) solve(go, sz[go] > sz[u] ? z - sz[u] : sz[go]);
}

int main() {
#ifdef isLOCAL
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif

    cin >> n;
    for (int i = 1; i <= n; ++i)
        scanf("%d", d + i);
    for (int i = 1, u, v, w; i < n; ++i)
        scanf("%d%d%d", &u, &v, &w), addE(u, v, w), addE(v, u, w);

    solve(1, n);
    printf("%d %.46lf\n", dans, ans);

    return 0;
}


#include<cstdio>
#include<cmath>
#include<vector>

using namespace std;

struct e
{
	int to;double val;
	e(int t=0,double v=0):to(t),val(v){}
};vector<e> ed[400000];

double w[400000];
int sz[400000],maxsz[400000];double dis[400000];
bool ban[400000];
vector<int> all_nd;
void dfs_bas(int u,int f)
{
	if(ban[u])return;
	all_nd.push_back(u);
	sz[u]=1,maxsz[u]=0;int maxv=0;
	for(int i=0;i<ed[u].size();i++)
	{
		int v=ed[u][i].to;if(v==f)continue;
		dfs_bas(v,u);
		sz[u]+=sz[v];maxsz[u]=max(maxsz[u],sz[v]);
	}
}

double der[400000];
double dfs_calc(int u,int f)
{
	der[u]=w[u]*1.5*pow(dis[u],0.5);double sum=w[u]*pow(dis[u],1.5);
	for(int i=0;i<ed[u].size();i++)
	{
		int v=ed[u][i].to;if(v==f)continue;
		dis[v]=dis[u]+ed[u][i].val;sum+=dfs_calc(v,u);der[u]+=der[v];
	}
	return sum;
}
double ans;int pos;
void work(int u)
{
	int rt=0;all_nd.clear();dfs_bas(u,0);
	for(int i=0;i<all_nd.size();i++)if(rt==0||max(sz[u]-sz[all_nd[i]],maxsz[all_nd[i]])<=(sz[u]>>1))rt=all_nd[i];
	if(!rt)return;dis[rt]=0;double sum=dfs_calc(rt,0);
	if(ans>sum){ans=sum,pos=rt;}
	ban[rt]=1;double sumd=der[rt];
	//printf("%d %d\n",u,rt);
	for(int i=0;i<ed[rt].size();i++)
	{
		int v=ed[rt][i].to;if(!ban[v]&&sumd-2*der[v]<0){work(v);break;}
	}
}

int main()
{
	int n=0;scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%lf",&w[i]);
	for(int i=1,x=0,y=0;i<n;i++)
	{
		double v=0;scanf("%d%d%lf",&x,&y,&v);ed[x].push_back(e(y,v)),ed[y].push_back(e(x,v));
	}
	ans=1e20;work(1);printf("%d %.10lf",pos,ans);return 0;
}


#include<cstdio>
#include<cmath>
#include<vector>

using namespace std;

struct e
{
	int to;double val;
	e(int t=0,double v=0):to(t),val(v){}
};vector<e> ed[400000];

double w[400000];
int sz[400000],maxsz[400000];double dis[400000];
bool ban[400000];
vector<int> all_nd;
void dfs_bas(int u,int f)
{
	if(ban[u])return;
	all_nd.push_back(u);
	sz[u]=1,maxsz[u]=0;int maxv=0;
	for(int i=0;i<ed[u].size();i++)
	{
		int v=ed[u][i].to;if(v==f)continue;
		dfs_bas(v,u);
		sz[u]+=sz[v];maxsz[u]=max(maxsz[u],sz[v]);
	}
}

double der[400000];
double dfs_calc(int u,int f)
{
	der[u]=w[u]*1.5*pow(dis[u],0.5);double sum=w[u]*pow(dis[u],1.5);
	for(int i=0;i<ed[u].size();i++)
	{
		int v=ed[u][i].to;if(v==f)continue;
		dis[v]=dis[u]+ed[u][i].val;sum+=dfs_calc(v,u);der[u]+=der[v];
	}
	return sum;
}
double ans;int pos;
void work(int u)
{
	int rt=0;dfs_bas(u,0);
	for(int i=0;i<all_nd.size();i++)if(max(sz[u]-sz[all_nd[i]],maxsz[all_nd[i]])<=(sz[u]>>1))rt=all_nd[i];
	dis[rt]=0;double sum=dfs_calc(rt,0);
	if(ans>sum){ans=sum,pos=rt;}
	ban[rt]=1;double sumd=der[rt];
	//printf("%d\n",rt);
	for(int i=0;i<ed[rt].size();i++)
	{
		int v=ed[rt][i].to;if(!ban[v]&&sumd-2*der[v]<0){work(v);break;}
	}
}

int main()
{
	int n=0;scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%lf",&w[i]);
	for(int i=1,x=0,y=0;i<n;i++)
	{
		double v=0;scanf("%d%d%lf",&x,&y,&v);ed[x].push_back(e(y,v)),ed[y].push_back(e(x,v));
	}
	ans=1e18;work(1);printf("%d %.10lf",pos,ans);return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define reg register
#define maxn 400005
inline ll read()
{
	reg ll x=0,w=0;reg char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,rt,maxd,a[maxn],ans1,size[maxn],bid[maxn];
double sum,ans2=-1,sumd,d[maxn];
inline void Max(int &x,int y){x=x>y?x:y;}
int headd[maxn],to[maxn],val[maxn],nextt[maxn],cntt=1;
inline void link(int u,int v,int w)
{nextt[++cntt]=headd[u];headd[u]=cntt;to[cntt]=v;val[cntt]=w;}
inline void get_rt(int u,int f,int zs)
{
	size[u]=1;reg int md=0;
	for(reg int i=headd[u];i;i=nextt[i])
	{
		if(to[i]==f||bid[to[i]])continue;
		get_rt(to[i],u,zs);
		size[u]+=size[to[i]];
		Max(md,size[to[i]]);
	}Max(md,zs-size[u]);
	if(md<maxd)maxd=md,rt=u;
}
inline void calc(int u,int f,int dis,int o)
{
	sum+=(double)a[u]*pow(dis,1.5);
	d[o]+=(double)a[u]*pow(dis,0.5)*1.5;
	for(reg int i=headd[u];i;i=nextt[i])
		if(to[i]!=f)calc(to[i],u,dis+val[i],o);
}
inline void solve(int u,int zs)
{
	maxd=zs;get_rt(u,0,zs);get_rt(rt,0,zs);
	bid[rt]=1;reg int i;sumd=sum=0;
	for(i=headd[rt];i;i=nextt[i])
		d[to[i]]=0,calc(to[i],rt,val[i],to[i]),sumd+=d[to[i]];
	if(ans2<0||sum<ans2)ans1=rt,ans2=sum;
	for(i=headd[rt];i;i=nextt[i])
		if(!bid[to[i]]&&sumd-2*d[to[i]]<0)
			solve(to[i],size[to[i]]);
}
int main()
{
	n=read();reg int i,u,v,w;
	for(i=1;i<=n;++i)a[i]=read();
	for(i=1;i<n;++i)
	{
		u=read(),v=read(),w=read();
		link(u,v,w);link(v,u,w);
	}
	solve(1,n);printf("%d %.10lf\n",ans1,ans2);
	return 0;
}


/*
    点分治 + 求导
*/
#include <bits/stdc++.h>
#define N 200005

using namespace std;

int n, wp;
int c[N];

double ans = 1e18;

vector<pair<int, int> > g[N];

inline int read() {
	int x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x;
}

int root, Size, mSize, siz[N];
double dir, sum, sumd[N];
bool vis[N];

void getRoot(int u, int fa) {
	siz[u] = 1;
	for(int i = g[u].size() - 1, v; ~i; --i) {
		v = g[u][i].first;
		if(v == fa || vis[v]) continue;
		getRoot(v, u), siz[u] += siz[v];
	}
	if(max(siz[u], Size - siz[u]) < mSize) {
		mSize = max(siz[u], Size - siz[u]);
		root = u;
	}
}

void getAns(int u, int fa, double dist) {
	sum += pow(dist, 1.5) * c[u];
	for(int i = g[u].size() - 1, v; ~i; --i) {
		v = g[u][i].first;
		if(v == fa) continue;
		getAns(v, u, dist + g[u][i].second);
	}
}
double getDir(int u, int fa, double dist) {
	double res = 1.5 * sqrt(dist) * c[u];
	for(int i = g[u].size() - 1, v; ~i; --i) {
		v = g[u][i].first;
		if(v == fa || vis[v]) continue;
		res += getDir(v, u, dist + g[u][i].second);
	}
	return res;
}

void solve(int u) {
	mSize = N;
	getRoot(u, u);
	vis[u = root] = true;

	sum = 0, getAns(u, u, 0);
	if(sum < ans) ans = sum, wp = u;

	dir = 0;
	for(int i = g[u].size() - 1, v; ~i; --i) {
		v = g[u][i].first;
		if(vis[v]) continue;
		sumd[v] = getDir(v, u, 0);
		dir += sumd[v];
	}
	for(int i = g[u].size() - 1, v; ~i; --i) {
		v = g[u][i].first;
		if(vis[v] || dir - 2 * sumd[v] > 0) continue;
		Size = siz[v];
		solve(v);
		break;
	}
}

int main() {
	n = read();
	for(int i = 1; i <= n; ++i)
		c[i] = read();
	for(int i = 1, u, v, w; i < n; ++i) {
		u = read(), v = read(), w = read();
		g[u].push_back(make_pair(v, w));
		g[v].push_back(make_pair(u, w));
	}

	Size = n;
	solve(1);

	printf("%d %.8lf", wp, ans);
	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ri register int
#define rll register long long
char *p1,*p2,buf[1<<20];
//#define GC (p1==p2&&(p1=buf,p2=buf+fread(buf,1,1<<20,stdin),p1==p2)?0:(*(p1++)))
#define GC getchar()
inline ll read()
{
	ll x;
	char t;
	bool k;
	while((t=GC)!='-'&&(t>'9'||t<'0'));
	k=(t=='-');
	x=k?0:(t-'0');
	while((t=GC)>='0'&&t<='9')
		x=x*10+t-'0';
	return k?-x:x;
}
//--------------------------------------------------
const ll Maxn=200005;
ll N,NN;
ll End[Maxn<<1],Next[Maxn<<1],Len[Maxn<<1],Last[Maxn],cntl;
double F[Maxn<<1];
//ll Fa[Maxn];

ll W[Maxn];

bool Mark[Maxn];

ll Size[Maxn];
ll G;

double Sum;
double TOT;

ll Ans1;
double Ans2;
//--------------------------------------------------
void Addedge(ll x,ll y,ll l)
{
	End[++cntl]=y;
	Len[cntl]=l;
	Next[cntl]=Last[x];
	Last[x]=cntl;
}

void GetG(ll x,ll Fa,ll num)
{
	Size[x]=1;
	ll temp=0;
	for(ri i=Last[x];i;i=Next[i])
	{
		ll y=End[i];
		if(!Mark[y]&&y!=Fa)
		{
			GetG(y,x,num);
			Size[x]+=Size[y];
			temp=max(temp,Size[y]);
		}
	}
	temp=max(temp,num-Size[x]);
	G=temp<<1<=num?x:G;
}

double DFS1(ll x,ll Fa,ll Dis)
{
//	printf("DFS1 x==%lld Dis==%lld\n",x,Dis);
	TOT+=(double)W[x]*sqrt(Dis)*(double)Dis;
	double Re=(double)W[x]*sqrt(Dis);
	for(ri i=Last[x];i;i=Next[i])
	{
		ll y=End[i];
		if(y!=Fa)//整棵树所以不判Mark
		{
			Re+=DFS1(y,x,Dis+Len[i]);
		}
	}
	return Re;
}
void Solve(ll x,ll num)
{
	G=0;
	GetG(x,0,num);
//	G=4;
//	printf("Into==>%lld\n",G);
	x=G;
	Mark[x]=1;

	Sum=0.0;
	TOT=0.0;
	for(ri i=Last[x];i;i=Next[i])
	{
		ll y=End[i];
		F[i]=DFS1(y,x,Len[i]);
		Sum+=F[i];
	}
	if(TOT<Ans2)
	{
		Ans1=x;
		Ans2=TOT;
//		printf("Cnange x==%lld Ans==%lf\n",x,Ans2);
	}
	for(ri i=Last[x];i;i=Next[i])
	{
		ll y=End[i];
		if(!Mark[y])
		{
			if((Sum-F[i]*2.0)<0.0)
			{
				Solve(y,Size[y]<Size[x]?Size[y]:num-Size[x]);
				break;
			}
		}
	}
}

//--------------------------------------------------
int main()
{
	Ans2=1e18*1.0;
	ll x,y,l;
	N=read();
	NN=N+1;
	for(ri i=1;i!=NN;++i)
	{
		W[i]=read();
	}
	for(ri i=1;i!=N;++i)
	{
		x=read(),y=read(),l=read();
		Addedge(x,y,l);
		Addedge(y,x,l);
	}
	Solve(1,N);
	printf("%lld %.10lf\n",Ans1,Ans2);
	return 0;
}
/*
  wi * di^0.5 - 2* A[i]
*/


#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
const int N=2e5+5;
int n,val[N],sz[N],w[N],vis[N],sum,rt;
double sd[N],S,sumd;
vector<pair<int,int> >E[N];
pair<double,int>ans;
void dfs(int u,int f){
	sz[u]=1;w[u]=0;
	for(auto x:E[u]){
		int v=x.first;
		if(v==f||vis[v])continue;
		dfs(v,u);sz[u]+=sz[v];
		w[u]=max(w[u],sz[v]);
	}
	w[u]=max(w[u],sum-sz[u]);
	if(w[u]<w[rt])rt=u;
}
void dfs2(int u,int f,int d,int ac){
	S+=d*sqrt(d)*val[u];
	sd[ac]+=1.5*sqrt(d)*w[u];
	for(auto x:E[u])
		if(x.first!=f)
			dfs2(x.first,u,d+x.second,ac);
}
void solve(int u){
	vis[u]=1;S=sumd=0;
	for(auto x:E[u]){
		int v=x.first;
		sd[v]=0;dfs2(v,u,x.second,v);sumd+=sd[v];
	}
	ans=min(ans,{S,u});
	for(auto x:E[u]){
		int v=x.first;if(vis[v])continue;
		if(sumd-sd[v]-sd[v]<0){
			dfs(v,0);rt=0;sum=sz[v];
			dfs(v,0);solve(rt);
			break;
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&val[i]);
	for(int i=1,x,y,z;i<n;++i){
		scanf("%d%d%d",&x,&y,&z);
		E[x].push_back({y,z});
		E[y].push_back({x,z});
	}
	ans={1e18,0};w[0]=sum=n;dfs(1,0);solve(rt);
	printf("%d %.10lf\n",ans.second,ans.first);
	return 0;
}


#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
double sum[200005],b[200005],ans,inf=1e18,maxx;
int a[200005],n,rt,siz[200005],son[200005],h[200005],vis1[200005],cnt,sit;
struct l1{
	int to,next,v;
}p[400005];
void add(int x,int y,int v){
	cnt++;
	p[cnt].to=y;
	p[cnt].next=h[x];
	h[x]=cnt;
	p[cnt].v=v;
}
void dfs1(int x,int fa,int num){
	siz[x]=1;son[x]=0;
	for(int i=h[x];i;i=p[i].next){
		int y=p[i].to;
		if(y==fa||vis1[y]) continue;
		dfs1(y,x,num);
		if(siz[y]>siz[son[x]]) son[x]=y;
		siz[x]+=siz[y];
	}
	if(max(siz[son[x]],num-siz[x])<maxx){
		maxx=max(siz[son[x]],num-siz[x]);
		rt=x;
	}
}
void dfs2(int x,int fa,int fro){
	sum[x]=pow(fro,1.5)*a[x],b[x]=pow(fro,0.5)*1.5*a[x];
	for(int i=h[x];i;i=p[i].next){
		int y=p[i].to;
		if(y==fa) continue;
		dfs2(y,x,fro+p[i].v);
		sum[x]+=sum[y];b[x]+=b[y];
	}
}
void dfz(int x,int num){
	maxx=inf;rt=x;
	dfs1(x,0,num);
	int now_rt=rt;
	vis1[now_rt]=1;
	dfs2(now_rt,0,0);
	if(ans>sum[now_rt]) ans=min(ans,sum[now_rt]),sit=now_rt;
	for(int i=h[now_rt];i;i=p[i].next){
		int y=p[i].to;
		if(vis1[y]) continue;
		if(b[now_rt]-2*b[y]>=0) continue;
		dfz(y,siz[y]);
		break;
	}
}
int main(){
	ans=inf;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<n;i++){
		int x,y,v;
		scanf("%d%d%d",&x,&y,&v);
		add(x,y,v);add(y,x,v);
	}
	dfz(1,n);
	printf("%d %.10f",sit,ans);
}


#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
const int N=2e5+5;
int n,val[N],sz[N],w[N],vis[N],sum,rt;
double sd[N],S,sumd;
vector<pair<int,int> >E[N];
pair<double,int>ans;
void dfs(int u,int f){
	sz[u]=1;w[u]=0;
	for(auto x:E[u]){
		int v=x.first;
		if(v==f||vis[v])continue;
		dfs(v,u);sz[u]+=sz[v];
		w[u]=max(w[u],sz[v]);
	}
	w[u]=max(w[u],sum-sz[u]);
	if(w[u]<w[rt])rt=u;
}
void dfs2(int u,int f,int d,int ac){
	S+=d*sqrt(d)*val[u];
	sd[ac]+=1.5*sqrt(d)*w[u];
	for(auto x:E[u])
		if(x.first!=f)
			dfs2(x.first,u,d+x.second,ac);
}
void solve(int u){
	vis[u]=1;S=sumd=0;
	for(auto x:E[u]){
		int v=x.first;
		sd[v]=0;dfs2(v,u,x.second,v);sumd+=sd[v];
	}
	ans=min(ans,{S,u});
	for(auto x:E[u]){
		int v=x.first;if(vis[v])continue;
		if(sumd-sd[v]-sd[v]<0){
			dfs(v,0);rt=0;sum=sz[v];
			dfs(v,0);solve(rt);
			break;
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&val[i]);
	for(int i=1,x,y,z;i<n;++i){
		scanf("%d%d%d",&x,&y,&z);
		E[x].push_back({y,z});
		E[y].push_back({x,z});
	}
	ans={1e30,0};w[0]=sum=n;dfs(1,0);solve(rt);
	printf("%d %.10lf\n",ans.second,ans.first);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int Maxn = 200005;
int n, cnt, tot, root, w[Maxn], siz[Maxn], maxi[Maxn], head[Maxn];
double now, sum, d[Maxn];
bool vis[Maxn];
pair <int, double> ans;
struct edg
{
	int nxt, to, w;
} edge[2 * Maxn];
void add(int x, int y, int w)
{
	edge[++cnt] = (edg){head[x], y, w};
	head[x] = cnt;
}
void get_root(int u, int fa)
{
	siz[u] = maxi[u] = 1;
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		if (to != fa)
		{
			get_root(to, u);
			siz[u] += siz[to];
			maxi[u] = max(maxi[u], siz[to]);
		}
	}
	maxi[u] = max(maxi[u], tot - siz[u]);
	if (maxi[u] < maxi[root]) root = u;
}
void dfs(int u, int fa, int rt, int dis)
{
	now += dis * sqrt(dis) * w[u], d[rt] += sqrt(dis) * 1.5 * w[u];
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		if (to != fa) dfs(to, u, rt, dis + edge[i].w);
	}
}
void divide(int u)
{
	now = sum = 0;
	vis[u] = true;
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		d[to] = 0, dfs(to, u, to, edge[i].w), sum += d[to];
	}
	if (now < ans.second) ans = make_pair(u, now);
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		if (!vis[to] && sum - 2 * d[to] < 0)
		{
			get_root(to, u), root = 0, tot = siz[to], get_root(to, u);
			divide(root);
		}
	}
}
int main()
{
	ans.second = 1e18;
	maxi[0] = 0x3f3f3f3f;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &w[i]);
	for (int i = 1; i < n; i++)
	{
		int x, y, w;
		scanf("%d%d%d", &x, &y, &w);
		add(x, y, w), add(y, x, w);
	}
	tot = n, get_root(1, 0);
	divide(root);
	printf("%d %.10lf", ans.first, ans.second);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int Maxn = 200005;
int n, cnt, tot, root, w[Maxn], siz[Maxn], maxi[Maxn], head[Maxn];
double now, sum, d[Maxn];
bool vis[Maxn];
pair <int, double> ans;
struct edg
{
	int nxt, to, w;
} edge[2 * Maxn];
void add(int x, int y, int w)
{
	edge[++cnt] = (edg){head[x], y, w};
	head[x] = cnt;
}
void get_root(int u, int fa)
{
	siz[u] = maxi[u] = 1;
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		if (to != fa && !vis[to])
		{
			get_root(to, u);
			siz[u] += siz[to];
			maxi[u] = max(maxi[u], siz[to]);
		}
	}
	maxi[u] = max(maxi[u], tot - siz[u]);
	if (maxi[u] < maxi[root]) root = u;
}
void dfs(int u, int fa, int rt, int dis)
{
	now += dis * sqrt(dis) * w[u], d[rt] += sqrt(dis) * 1.5 * w[u];
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		if (to != fa) dfs(to, u, rt, dis + edge[i].w);
	}
}
void divide(int u)
{
	now = sum = 0;
	vis[u] = true;
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		d[to] = 0, dfs(to, u, to, edge[i].w), sum += d[to];
	}
	if (now < ans.second) ans = make_pair(u, now);
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		if (!vis[to] && sum - 2 * d[to] < 0)
		{
			get_root(to, u), root = 0, tot = siz[to], get_root(to, u);
			divide(root);
		}
	}
}
int main()
{
	ans.second = 1e50;
	maxi[0] = 0x3f3f3f3f;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &w[i]);
	for (int i = 1; i < n; i++)
	{
		int x, y, w;
		scanf("%d%d%d", &x, &y, &w);
		add(x, y, w), add(y, x, w);
	}
	tot = n, get_root(1, 0);
	divide(root);
	printf("%d %.10lf", ans.first, ans.second);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int Maxn = 200005;
int n, cnt, tot, root, w[Maxn], siz[Maxn], maxi[Maxn], head[Maxn];
double now, sum, d[Maxn];
bool vis[Maxn];
pair <int, double> ans;
struct edg
{
	int nxt, to, w;
} edge[2 * Maxn];
void add(int x, int y, int w)
{
	edge[++cnt] = (edg){head[x], y, w};
	head[x] = cnt;
}
void get_root(int u, int fa)
{
	siz[u] = maxi[u] = 1;
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		if (to != fa && !vis[to])
		{
			get_root(to, u);
			siz[u] += siz[to];
			maxi[u] = max(maxi[u], siz[to]);
		}
	}
	maxi[u] = max(maxi[u], tot - siz[u]);
	if (maxi[u] < maxi[root]) root = u;
}
void dfs(int u, int fa, int rt, int dis)
{
	now += dis * sqrt(dis) * w[u], d[rt] += sqrt(dis) * 1.5 * w[u];
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		if (to != fa) dfs(to, u, rt, dis + edge[i].w);
	}
}
void divide(int u)
{
	now = sum = 0;
	vis[u] = true;
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		d[to] = 0, dfs(to, u, to, edge[i].w), sum += d[to];
	}
	if (now < ans.second) ans = make_pair(u, now);
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		if (!vis[to] && sum - 2 * d[to] < 0)
		{
			get_root(to, u), root = 0, tot = siz[to], get_root(to, u);
			divide(root);
		}
	}
}
int main()
{
	ans.second = 1e18;
	maxi[0] = 0x3f3f3f3f;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &w[i]);
	for (int i = 1; i < n; i++)
	{
		int x, y, w;
		scanf("%d%d%d", &x, &y, &w);
		add(x, y, w), add(y, x, w);
	}
	tot = n, get_root(1, 0);
	divide(root);
	printf("%d %.10lf", ans.first, ans.second);
	return 0;
}


#include<bits/stdc++.h>

#define LL long long
#define RG register
using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 2e5 + 10;
struct node { int to, nxt, w; } g[N << 1];
int lst[N], gl, w[N];
void add(int z, int y, int x) {
	g[++gl] = (node) {y, lst[x], z}; lst[x] = gl;
	g[++gl] = (node) {x, lst[y], z}; lst[y] = gl;
}
int ans1;
double ans2;
int siz[N], mx, rt, sum;
bool vis[N];
void getroot(int u, int ff) {
	siz[u] = 1;
	int s = 0;
	for (int i = lst[u]; i; i = g[i].nxt) {
		int v = g[i].to; if (v == ff || vis[v]) continue;
		getroot(v, u); siz[u] += siz[v];
		s = max(s, siz[v]);
	}
	s = max(s, sum - siz[u]);
	if (s < mx) mx = s, rt = u;
}
double sd[N], sumd, ans;
void dfs(int u, int ff, int tp, double dep) {
	ans += sqrt(dep) * dep * w[u];
	sumd += 1.5 * sqrt(dep) * w[u];
	sd[tp] += 1.5 * sqrt(dep) * w[u];
	for (int i = lst[u]; i; i = g[i].nxt) {
		int v = g[i].to; if (v == ff) continue;
		dfs(v, u, tp, dep + g[i].w);
	}
}

void solve(int u) {
	vis[u] = 1; ans = sumd = 0;
	for (int i = lst[u]; i; i = g[i].nxt)
		sd[g[i].to] = 0, dfs(g[i].to, u, g[i].to, g[i].w);
	if (ans2 > ans) ans1 = u, ans2 = ans;
	for (int i = lst[u]; i; i = g[i].nxt) {
		int v = g[i].to; if (vis[v]) continue;
		if (sumd - sd[v] > sd[v]) continue;
		mx = sum = siz[v]; getroot(v, u); solve(rt);
	}
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n = gi<int>();
	for (int i = 1; i <= n; i++) w[i] = gi<int>();
	for (int i = 1; i < n; i++) add(gi<int>(), gi<int>(), gi<int>());
	ans2 = 1e20;
	mx = sum = n; getroot(1, 0); solve(rt);
	printf("%d %.10lf\n", ans1, ans2);
	return 0;
}