#include <bits/stdc++.h>
using namespace std;
const int N = 400000 + 20;
long long G, cnt, n, pos, head[N], size[N], a[N];
double len[N << 1], ans;
bool vis[N];
struct node {
  long long to, next;
  long long dis;
};
node p[N << 1];
void addedge(long long x, long long y, long long z) {
  cnt++;
  p[cnt].to = y;
  p[cnt].next = head[x];
  p[cnt].dis = z;
  head[x] = cnt;
}
void find_G(long long x, long long fa, long long al) {
  size[x] = 1;
  long long mx = 0;
  for (long long i = head[x]; i; i = p[i].next) {
    long long y = p[i].to;
    if (y != fa && !vis[y]) {
      find_G(y, x, al);
      size[x] += size[y];
      mx = max(mx, size[y]);
    }
  }
  mx = max(mx, al - size[x]);
  G = mx << 1 <= al ? x : G;
}
double tot, sum;
void dfs_collect(long long x, long long fa, long long dis, long long edge) {
  double qwq = a[x] * sqrt(dis);
  len[edge] += qwq;
  sum += qwq;
  tot += (double)a[x] * sqrt(dis) * (double)dis;
  for (int i = head[x]; i; i = p[i].next)
    if (p[i].to != fa) dfs_collect(p[i].to, x, dis + p[i].dis, edge);
}
void solve(long long x, long long al) {
  G = 0;
  find_G(x, 0, al);
  vis[x = G] = 1;
  tot = 0.0;
  sum = 0.0;
  for (long long i = head[x]; i; i = p[i].next) {
    long long y = p[i].to;
    dfs_collect(y, x, p[i].dis, i);
  }
  if (tot < ans) {
    pos = x;
    ans = tot;
  }
  for (long long i = head[x]; i; i = p[i].next) {
    long long y = p[i].to;
    if (!vis[y] && (sum - len[i] * 2.0) < 0.0) {
      solve(y, size[x] > size[y] ? size[y] : al - size[x]);
    }
  }
}
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  long long x, y, z;
  ans = 1e40;
  for (long long i = 1; i < n; i++) {
    scanf("%lld%lld%lld", &x, &y, &z);
    addedge(x, y, z);
    addedge(y, x, z);
  }
  solve(1, n);
  printf("%lld %.6lf", pos, ans);
  return 0;
}
