#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return s;
}
const int N = 2e5 + 5;
int n;
int w[N], vis[N], siz[N], mn[N];
int rt, tot;
vector<pair<int, int> > G[N];
double sum, sumd, ans = 1e20;
int p;
double d[N];
void get_siz(int u, int f) {
  siz[u] = 1;
  for (auto p : G[u]) {
    int v = p.first;
    if (v != f && !vis[v]) {
      get_siz(v, u);
      siz[u] += siz[v];
    }
  }
}
void get_rt(int u, int f) {
  int s = 0;
  for (auto p : G[u]) {
    int v = p.first;
    if (v != f && !vis[v]) {
      get_rt(v, u);
      s = max(s, siz[v]);
    }
  }
  mn[u] = max(s, tot - siz[u]);
  if (mn[u] < mn[rt]) rt = u;
}
inline void calc(int u, int fr, int f, int dep) {
  sum += dep * sqrt(dep) * w[u], sumd += sqrt(dep) * 3.0 / 2 * w[u],
      d[fr] += sqrt(dep) * 3.0 / 2 * w[u];
  for (auto p : G[u]) {
    if (p.first != f) calc(p.first, fr, u, dep + p.second);
  }
}
void dfs(int u) {
  vis[u] = 1;
  sum = sumd = 0;
  get_siz(u, 0);
  for (auto e : G[u]) {
    int v = e.first;
    d[v] = 0;
    calc(v, v, u, e.second);
  }
  if (sum < ans) ans = sum, p = u;
  for (auto e : G[u]) {
    int v = e.first;
    if (vis[v]) continue;
    if (sumd - d[v] * 2 < 0) {
      rt = 0;
      tot = siz[v];
      get_rt(v, 0);
      dfs(rt);
      break;
    }
  }
}
int main() {
  n = read();
  mn[0] = 1e9;
  for (int i = 1; i <= n; i++) w[i] = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read(), w = read();
    G[u].push_back({v, w});
    G[v].push_back({u, w});
  }
  get_siz(1, 0);
  tot = n, rt = 0;
  get_rt(1, 0);
  dfs(rt);
  printf("%d %.10lf", p, ans);
  return 0;
}
