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;
const int N = 2e5 + 5;
int n;
double w[N];
int x, y;
double z;
int fi[N], nt[N * 2], to[N * 2], tot = 1;
double v[N * 2];
void link(int x, int y, double z) {
  nt[++tot] = fi[x], to[tot] = y, v[tot] = z, fi[x] = tot;
  nt[++tot] = fi[y], to[tot] = x, v[tot] = z, fi[y] = tot;
}
int siz[N], mx[N], G;
int bz[N];
void fg(int x) {
  bz[x] = 1;
  mx[x] = 0;
  siz[x] = 1;
  for (int i = fi[x]; i; i = nt[i]) {
    int y = to[i];
    if (!bz[y])
      fg(y), siz[x] += siz[y], ((mx[x]) < (siz[y]) ? (mx[x]) = (siz[y]) : 0);
  }
  ((mx[x]) < (siz[0] - siz[x]) ? (mx[x]) = (siz[0] - siz[x]) : 0);
  if (mx[x] < mx[G]) G = x;
  bz[x] = 0;
}
double dis[N], d[N], d2[N], p[N], q[N];
int d0;
int l[N], r[N];
int bx[N];
void dfs(int x) {
  bx[x] = 1;
  d[++d0] = dis[x], d2[d0] = w[x];
  l[x] = d0;
  for (int i = fi[x]; i; i = nt[i])
    if (!bx[to[i]]) {
      int y = to[i];
      dis[y] = dis[x] + v[i];
      dfs(y);
    }
  r[x] = d0;
  bx[x] = 0;
}
double ans = 1e18;
int ans2;
void calc(int x) {
  double sum = 0;
  for (int i = 1, B = d0; i <= B; i++) sum += pow(d[i], 1.5) * d2[i];
  if (sum < ans) ans = sum, ans2 = x;
}
void dg(int x) {
  fg(x);
  d0 = 0;
  dis[x] = 0;
  dfs(x);
  calc(x);
  p[0] = 0;
  for (int i = 1, B = d0; i <= B; i++)
    p[i] = p[i - 1] + pow(d[i] + 1, 1.5) * d2[i];
  q[d0 + 1] = 0;
  for (int i = d0, B = 1; i >= B; i--)
    q[i] = q[i + 1] + pow(d[i] + 1, 1.5) * d2[i];
  int cho = 0;
  double ms = 1e18;
  for (int i = fi[x]; i; i = nt[i])
    if (!bz[to[i]]) {
      int y = to[i];
      double sum = p[l[y] - 1] + q[r[y] + 1];
      for (int j = l[y], B = r[y]; j <= B; j++)
        sum += pow(d[j] - 1, 1.5) * d2[j];
      if (sum < ms) cho = y, ms = sum;
    }
  bz[x] = 1;
  if (cho) {
    siz[0] = siz[cho], G = 0, fg(cho);
    dg(G);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1, B = n; i <= B; i++) scanf("%lf", &w[i]);
  for (int i = 1, B = n - 1; i <= B; i++) {
    scanf("%d %d %lf", &x, &y, &z);
    link(x, y, z);
  }
  siz[0] = mx[0] = n, G = 0, fg(1), dg(G);
  printf("%d %.6lf\n", ans2, ans);
}
