#include <bits/stdc++.h>
using namespace std;
double ans, ANS, val[200005];
vector<int> V[200005], son[200005];
int a[200005], vst[200005], nd, root;
long long sz[200005], S;
void pre(int now, int fat) {
  sz[now] = a[now];
  for (int T, i = 0; i < son[now].size(); ++i)
    if ((T = son[now][i]) != fat && !vst[T]) pre(T, now), sz[now] += sz[T];
}
void rt(int now, int fat) {
  long long mx = S - sz[now];
  for (int T, i = 0; i < son[now].size(); ++i)
    if ((T = son[now][i]) != fat && !vst[T]) rt(T, now), mx = max(mx, sz[T]);
  if (mx <= (S >> 1)) root = now;
}
void solve(int now, int fat, int dis) {
  ANS += sqrt(dis) * a[now] * dis;
  val[now] = sqrt(dis) * a[now];
  for (int T, i = 0; i < son[now].size(); ++i)
    if ((T = son[now][i]) != fat)
      solve(T, now, dis + V[now][i]), val[now] = val[now] + val[T];
}
void dfs(int now) {
  if (vst[now]) return;
  pre(now, 0);
  S = sz[now];
  rt(now, 0);
  vst[now = root] = 1;
  ANS = 0;
  solve(now, 0, 0);
  if (ANS < ans) ans = ANS, nd = now;
  int i, T;
  double mn = 0;
  for (i = 0; i < son[now].size(); ++i)
    if (val[son[now][i]] > mn) mn = val[T = son[now][i]];
  dfs(T);
}
int n, i, x, y, v;
int main() {
  cin >> n;
  for (i = 1; i <= n; ++i) cin >> a[i];
  for (i = 1; i < n; ++i)
    cin >> x >> y >> v, son[x].push_back(y), son[y].push_back(x),
        V[x].push_back(v), V[y].push_back(v);
  ans = 1e30;
  dfs(1);
  printf("%d %.10lf", nd, ans);
}
