#include <bits/stdc++.h>
const int N = 2e5;
const double eps = 1e-8;
using namespace std;
struct edges {
  int to, cost;
} edge[N * 2 + 5];
int n, a[N + 5], nxt[N * 2 + 5], head[N + 5], edge_cnt, maxp[N + 5], rt,
    size[N + 5], sm, dis[N + 5], vis[N + 5], co[N + 5], id;
double ans, f[N + 5];
void add_edge(int u, int v, int w) {
  edge[++edge_cnt] = (edges){v, w};
  nxt[edge_cnt] = head[u];
  head[u] = edge_cnt;
}
void dfs(int u, int fa) {
  size[u] = 1;
  maxp[u] = 0;
  for (int i = head[u]; i; i = nxt[i]) {
    int v = edge[i].to;
    if (vis[v] || v == fa) continue;
    dfs(v, u);
    size[u] += size[v];
    maxp[u] = max(maxp[u], size[v]);
  }
  maxp[u] = max(maxp[u], sm - size[u]);
  if (maxp[u] < maxp[rt]) rt = u;
}
void getdis(int u, int fa, int c) {
  co[u] = c;
  f[u] = 1.5 * pow(dis[u], 0.5) * a[u];
  for (int i = head[u]; i; i = nxt[i]) {
    int v = edge[i].to, w = edge[i].cost;
    if (v == fa) continue;
    dis[v] = dis[u] + w;
    getdis(v, u, c);
    f[u] += f[v];
  }
}
int calc(int u) {
  dis[u] = 0;
  for (int i = head[u]; i; i = nxt[i]) {
    int v = edge[i].to, w = edge[i].cost;
    dis[v] = w;
    getdis(v, u, v);
  }
  double s = 0;
  for (int i = 1; i <= n; i++) s += pow(dis[i], 1.5) * a[i];
  if (ans == -1) ans = s, id = u;
  if (s - ans < eps) ans = s, id = u;
  s = 0;
  for (int i = head[u]; i; i = nxt[i]) {
    int v = edge[i].to;
    s += f[v];
  }
  for (int i = head[u]; i; i = nxt[i]) {
    int v = edge[i].to;
    if (s - 2 * f[v] < 0) return v;
  }
  return 0;
}
void solve(int u) {
  vis[u] = 1;
  int son = calc(u);
  if (vis[son] || !son) return;
  rt = 0;
  maxp[rt] = sm = size[son];
  dfs(son, 0);
  solve(rt);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int u, v, w;
  for (int i = 1; i < n; i++) {
    scanf("%d%d%d", &u, &v, &w);
    add_edge(u, v, w);
    add_edge(v, u, w);
  }
  maxp[rt] = sm = n;
  ans = -1;
  dfs(1, 0);
  solve(rt);
  printf("%d %.10lf", id, ans);
  return 0;
}
