#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
int size[N], vis[N], fst[N], nxt[N], ansu, w[N], mm, n, m, nn, mxsize, root;
double anss = 1e60, d[N], s;
struct Edge {
  int v, w;
} e[N];
void ade(int u, int v, int w) {
  e[++mm] = (Edge){v, w}, nxt[mm] = fst[u], fst[u] = mm;
}
void findroot(int u, int fa, int nn) {
  size[u] = 1;
  int mx = 0;
  for (int i = fst[u]; i; i = nxt[i]) {
    int v = e[i].v;
    if (v == fa || vis[v]) continue;
    findroot(v, u, nn), size[u] += size[v];
    mx = max(mx, size[v]);
  }
  mx = max(mx, nn - size[u]);
  if (mx < mxsize) root = u, mxsize = mx;
}
void calc(int u, int fa, int dep, int anc) {
  d[anc] += sqrt(dep) * w[u];
  s += sqrt(dep) * dep * w[u];
  for (int i = fst[u]; i; i = nxt[i]) {
    int v = e[i].v;
    if (v == fa) continue;
    calc(v, u, dep + e[i].w, anc);
  }
}
void solve(int u) {
  vis[u] = 1;
  s = 0;
  double sd = 0;
  for (int i = fst[u]; i; i = nxt[i]) {
    int v = e[i].v;
    d[v] = 0;
    calc(v, u, e[i].w, v);
    sd += d[v];
  }
  if (s < anss) anss = s, ansu = u;
  for (int i = fst[u]; i; i = nxt[i]) {
    int v = e[i].v;
    if (vis[v]) continue;
    if (sd - 2 * d[v] >= 0) continue;
    mxsize = 1e9, findroot(v, u, size[v]), solve(root);
    return;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", w + i);
  for (int i = 1, u, v, w; i < n; i++) {
    scanf("%d%d%d", &u, &v, &w), ade(u, v, w), ade(v, u, w);
  }
  mxsize = 1e9, findroot(1, 0, n), solve(root);
  printf("%d %.10lf\n", ansu, anss);
}
