3
1 1 5
1 3 42
1 2 42
 2
42 23
1 2 10
 10
45792697 27183921 4791060 77070594 27286110 66957065 19283638 2944837 26775511 65379701
5 8 25
8 10 94
1 4 14
9 7 96
4 2 16
2 6 58
2 3 99
6 8 21
8 9 87
 5
3 1 2 6 5
1 2 3
2 3 1
4 3 9
5 3 1
 10
26 31 21 57 56 44 54 58 79 97
2 1 277
1 8 91
1 7 380
4 1 649
10 5 799
10 1 940
8 6 627
6 3 177
9 6 685
 10
8 100 62 38 26 51 26 23 77 32
6 8 29
4 1 82
7 8 66
7 10 67
8 9 98
6 1 14
1 5 48
3 1 58
2 9 90
 2
23 42
1 2 10
 1
42
 3
1 5 1
1 3 42
1 2 42
 10
1 1 1 1 1 1 1 1 1 1
1 2 5
1 3 5
1 4 5
1 5 5
1 6 5
1 7 5
1 8 5
1 9 5
1 10 5
 3
1 1 1
1 2 42
2 3 42
 3
5 1 1
1 3 42
1 2 24

3 1042.0638260857 1 727.3238618387 6 283959805416.40496826
 3 192.0000000000 1 13952642.4776933547 8 544327.1927847408 2 727.3238618387 1 0.0000000000 2 1042.0638260857 1 100.6230589875 2 544.3822186663 1 389.7666169867
#include <bits/stdc++.h>
using namespace std;
int n;
double w[(int)2e5 + 5];
int h[(int)2e5 + 5], tot = 1;
int vis[(int)2e5 + 5], siz[(int)2e5 + 5];
double VAL[(int)2e5 + 5], ans[(int)2e5 + 5];
struct edge {
  int to, nxt, Vis;
  double val;
} e[(int)4e5 + 5];
void add(int x, int y, double z) {
  e[++tot] = (edge){y, h[x], 0, z};
  h[x] = tot;
}
double deal(int k, double far, int fa) {
  double ans = 0.0;
  for (int u = h[k]; u; u = e[u].nxt)
    if (e[u].to != fa) ans += deal(e[u].to, far + e[u].val, k);
  if (vis[k]) VAL[k] = ans + w[k] * far * sqrt(far) * 1.0;
  return ans + w[k] * far * sqrt(far) * 1.0;
}
const bool cmp_double(double t1, double t2) {
  if (t1 >= t2 - 0.000001 && t1 <= t2 + 0.000001) return 1;
  return 0;
}
int get_siz(int k) {
  vis[k] = 1;
  int kid = 0;
  for (int u = h[k]; u; u = e[u].nxt)
    if (!vis[e[u].to] && !e[u].Vis) kid += get_siz(e[u].to);
  vis[k] = 0;
  return kid + 1;
}
int dfs2(int k, int Siz) {
  vis[k] = 1, siz[k] = 1;
  int ok = 1, K, _K = 0x7fffffff;
  for (int u = h[k]; u; u = e[u].nxt)
    if (!vis[e[u].to] && !e[u].Vis) {
      K = dfs2(e[u].to, Siz);
      if (K != 0x7fffffff) _K = K;
      siz[k] += siz[e[u].to];
      if (siz[e[u].to] > Siz / 2) ok = 0;
    }
  if (Siz - siz[k] > Siz / 2) ok = 0;
  if (ok) _K = min(_K, k);
  vis[k] = 0;
  return _K;
}
int get_h(int k) { return dfs2(k, get_siz(k)); }
void dfs1(int k, double minn_ans) {
  for (int u = h[k]; u; u = e[u].nxt)
    if (!e[u].Vis) vis[e[u].to] = 1;
  ans[k] = VAL[k] = deal(k, 0.0, k);
  for (int u = h[k]; u; u = e[u].nxt)
    if (!e[u].Vis) vis[e[u].to] = 0;
  int _k;
  double _k_val = 0.0;
  for (int u = h[k]; u; u = e[u].nxt)
    if (VAL[e[u].to] > _k_val) _k_val = VAL[e[u].to], _k = e[u].to;
  if (cmp_double(minn_ans, ans[k]))
    return;
  else if (ans[k] > minn_ans)
    return;
  dfs1(_k, ans[k]), printf("%d %.16lf", k, ans[k]), exit(0);
}
int main() {
  int i, j, k;
  int x, y;
  long long MAXN = 1ll << 62;
  double z;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%lf", &w[i]);
  if (n == 1) {
    printf("%d %.16lf", 1, 0.0);
    return 0;
  }
  for (i = 1; i < n; ++i) {
    scanf("%d%d%lf", &x, &y, &z);
    add(x, y, z), add(y, x, z);
  }
  z = MAXN, dfs1(get_h(1), z);
  return 0;
}
