#include <bits/stdc++.h>
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) * val[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;
}
