#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
template <class T>
inline void umin(T &x, T y) {
  x = x < y ? x : y;
}
template <class T>
inline void umax(T &x, T y) {
  x = x > y ? x : y;
}
inline unsigned int R() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
const int N = 266666;
int n, w[N];
int ans1;
double ans2 = 1e100, cur, ans[N];
bool gg[N];
int sz[N], T;
vector<pair<int, int> > e[N];
void getsz(int u, int fa) {
  sz[u] = 1;
  for (register int i = (0); i <= (((int)e[u].size()) - 1); i++)
    if (!gg[e[u][i].first] && e[u][i].first != fa)
      getsz(e[u][i].first, u), sz[u] += sz[e[u][i].first];
}
void getcen(int u, int fa, pair<int, int> &res) {
  int mx = T - sz[u];
  for (register int i = (0); i <= (((int)e[u].size()) - 1); i++)
    if (!gg[e[u][i].first] && e[u][i].first != fa)
      getcen(e[u][i].first, u, res), umax(mx, sz[e[u][i].first]);
  res = min(res, pair<int, int>(mx, u));
}
void getans(int u, int fa, long long dis, int bel) {
  cur += w[u] * dis * sqrt(dis);
  ans[bel] += w[u] * sqrt(dis);
  for (register int i = (0); i <= (((int)e[u].size()) - 1); i++)
    if (e[u][i].first != fa)
      getans(e[u][i].first, u, dis + e[u][i].second, bel);
}
void solve(int rt) {
  getsz(rt, 0);
  T = sz[rt];
  pair<int, int> res(1e9, rt);
  getcen(rt, 0, res);
  assert(res.first <= T / 2);
  rt = res.second;
  gg[rt] = 1;
  cur = 0;
  double sum = 0;
  cerr << rt << ' ' << T << ' ' << res.first << endl;
  for (register int i = (0); i <= (((int)e[rt].size()) - 1); i++) {
    ans[e[rt][i].first] = 0,
    getans(e[rt][i].first, rt, e[rt][i].second, e[rt][i].first),
    sum += ans[e[rt][i].first];
  }
  if (cur < ans2) ans2 = cur, ans1 = rt;
  for (register int i = (0); i <= (((int)e[rt].size()) - 1); i++)
    if (ans[e[rt][i].first] * 2 > sum && !gg[e[rt][i].first]) {
      solve(e[rt][i].first);
      break;
    }
}
int main() {
  read(n);
  for (register int i = (1); i <= (n); i++) read(w[i]);
  for (register int i = (1); i <= (n - 1); i++) {
    int u, v, w;
    read(u);
    read(v);
    read(w);
    e[u].push_back(pair<int, int>(v, w));
    e[v].push_back(pair<int, int>(u, w));
  }
  solve(1);
  printf("%d %.11lf\n", ans1, ans2);
  return 0;
}
