#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read() {
  T f = 0, x = 0;
  char c = getchar();
  while (!isdigit(c)) f = c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + c - 48, c = getchar();
  return f ? -x : x;
}
namespace run {
const int N = 2e5 + 9;
const double eps = 1e-12;
int n, val[N], head[N], nex[N << 1], to[N << 1], w[N << 1], cnt;
inline void add(int u, int v, int c) {
  nex[++cnt] = head[u], head[u] = cnt, to[cnt] = v, w[cnt] = c;
  nex[++cnt] = head[v], head[v] = cnt, to[cnt] = u, w[cnt] = c;
}
bool cut[N];
int siz[N], tot, mx, rt;
inline void getrt(int u, int _f) {
  siz[u] = 1;
  int _mx = 0;
  for (int i = head[u]; i; i = nex[i])
    if (to[i] ^ _f && !cut[to[i]]) {
      getrt(to[i], u), siz[u] += siz[to[i]];
      _mx = max(_mx, siz[to[i]]);
    }
  _mx = max(_mx, tot - siz[u]);
  if (_mx < mx) rt = u, mx = _mx;
}
double f[N], ans = 1e30, res;
int pos;
inline void dfs(int u, int _f, int dist) {
  f[u] = 1.5 * sqrt(dist) * val[u], res += 1. * val[u] * pow(dist, 1.5);
  for (int i = head[u]; i; i = nex[i])
    if (to[i] ^ _f) dfs(to[i], u, dist + w[i]), f[u] += f[to[i]];
}
inline void cess(int u, int _f) {
  siz[u] = 1;
  for (int i = head[u]; i; i = nex[i])
    if (to[i] ^ _f) cess(to[i], u), siz[u] += siz[to[i]];
}
inline void solve(int u, int _tot) {
  tot = _tot, mx = tot, rt = 0, getrt(u, 0);
  res = 0., dfs(rt, 0, 0), cut[rt] = 1;
  double sum = 0.;
  if (res < ans) ans = res, pos = rt;
  for (int i = head[rt]; i; i = nex[i]) sum += f[to[i]];
  for (int i = head[rt]; i; i = nex[i])
    if (sum - 2 * f[to[i]] < eps && !cut[to[i]])
      return cess(rt, to[i]), solve(to[i], siz[to[i]]);
}
int main() {
  n = read<int>();
  for (int i = 1; i <= n; i++) val[i] = read<int>();
  for (int i = 1; i < n; i++) {
    int u = read<int>(), v = read<int>(), c = read<int>();
    add(u, v, c);
  }
  solve(1, n);
  printf("%d %.10lf\n", pos, ans);
  return 0;
}
}  // namespace run
int main() { return run::main(); }
