#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;
const double inf = 1e100;
int sz[MAXN], v[MAXN], c, N;
double w[MAXN], cost[MAXN], grad[MAXN];
vector<pair<int, int> > g[MAXN];
pair<double, int> r(inf, 0);
int center(int i, int p, int tsz) {
  int sz = 1, msz = 0;
  for (pair<int, int> j : g[i])
    if (j.first != p && !v[j.first]) {
      int x = center(j.first, i, tsz);
      msz = max(msz, x);
      sz += x;
    }
  if (max(tsz - sz, msz) <= tsz / 2) c = i;
  return sz;
}
void dfs(int i, int p, int d) {
  grad[i] = sqrt(d) * w[i];
  cost[i] = d * grad[i];
  for (pair<int, int> j : g[i])
    if (j.first != p) {
      dfs(j.first, i, d + j.second);
      grad[i] += grad[j.first];
      cost[i] += cost[j.first];
    }
}
void solve(int i) {
  center(i, 0, center(i, 0, 0));
  dfs(c, 0, 0);
  v[c] = 1;
  double scost = 0, sgrad = 0;
  for (pair<int, int> j : g[c]) {
    scost += cost[j.first];
    if (!v[j.first]) sgrad += grad[j.first];
  }
  r = min(r, {scost, c});
  for (pair<int, int> j : g[c])
    if (!v[j.first] && sgrad - 2 * grad[j.first] < 0) {
      solve(j.first);
      return;
    }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%lf", &w[i]);
  for (int i = 1, x, y, l; i <= N - 1; i++) {
    scanf("%d%d%d", &x, &y, &l);
    g[x].push_back({y, l});
    g[y].push_back({x, l});
  }
  solve(1);
  printf("%d %20.20lf\n", r.second, r.first);
}
