#include <bits/stdc++.h>
using namespace std;
struct P {
  int u, c;
};
int val[200005], is[200005], pt, len, mi;
vector<P> s[200005];
double sub;
void dfs1(int u, int fa, int add) {
  int i;
  if (add >= len) len = add, pt = u;
  for (i = 0; i < s[u].size(); i++) {
    int v = s[u][i].u;
    if (v == fa || is[v]) continue;
    dfs1(v, u, add + s[u][i].c);
  }
}
int dfs2(int u, int fa, int add) {
  int sum = 0, i;
  for (i = 0; i < s[u].size(); i++) {
    int v = s[u][i].u;
    if (v == fa || is[v]) continue;
    int tmp = dfs2(v, u, add + s[u][i].c);
    sum = max(sum, tmp + s[u][i].c);
  }
  if (add + sum > len) len = add + sum;
  if (add + sum == len) {
    if (abs(add - sum) < mi || mi == -1) {
      mi = abs(add - sum);
      pt = u;
    }
  }
  return sum;
}
double dfs3(int u, int fa, int add) {
  int i;
  sub += (double)sqrt(add) * val[u];
  double tmp = (double)sqrt(add) * add * val[u];
  for (i = 0; i < s[u].size(); i++) {
    int v = s[u][i].u;
    if (v == fa) continue;
    tmp += dfs3(v, u, add + s[u][i].c);
  }
  return tmp;
}
int main() {
  int n, i, j, x, y, z;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &val[i]);
  }
  for (i = 1; i < n; i++) {
    scanf("%d%d%d", &x, &y, &z);
    s[x].push_back((P){y, z});
    s[y].push_back((P){x, z});
  }
  int next = 1, out;
  double ans = 1e25;
  while (1) {
    len = 0, mi = -1;
    dfs1(next, -1, 0);
    dfs2(pt, -1, 0);
    is[pt] = 1;
    double ma = 0, tmp = 0;
    for (i = 0; i < s[pt].size(); i++) {
      int v = s[pt][i].u;
      sub = 0;
      tmp += dfs3(v, pt, s[pt][i].c);
      if (sub >= ma) {
        ma = sub, next = v;
      }
    }
    if (tmp < ans) {
      ans = tmp, out = pt;
    }
    if (is[next]) break;
  }
  printf("%d %.10f\n", out, ans);
}
