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 an, n, a[200005], sz[200005];
vector<pair<int, int> > Ed[200005];
double Ans = 1e20, sm, d[200005];
bool bo[200005];
inline int IN() {
  char c;
  register int first = 0;
  for (; (c = getchar()) < 48 && c ^ '-' || c > 57;)
    ;
  bool f = c == '-';
  if (f) (c = getchar());
  for (; c > 47 && c < 58; (c = getchar())) first = first * 10 + c - 48;
  if (f) first = -first;
  return first;
}
int gsz(int u, int ff = 0) {
  for (pair<int, int> X : Ed[u])
    if (X.first ^ ff) sz[u] += gsz(X.first, u);
  return ++sz[u];
}
int grt(int u) {
  int maxx = 0, w;
  for (pair<int, int> W : Ed[u])
    if (!bo[W.first] && sz[W.first] > maxx) maxx = sz[W.first], w = W.first;
  if (maxx * 2 > sz[u]) {
    sz[u] -= sz[w];
    sz[w] += sz[u];
    return grt(w);
  }
  return u;
}
void dfs(int u, int ff = 0) {
  sm += a[u] * d[u] * sqrt(d[u]);
  for (pair<int, int> W : Ed[u]) {
    int v = W.first;
    if (v ^ ff) {
      d[v] = d[u] + W.second;
      dfs(v, u);
    }
  }
}
inline void gao(int u) {
  d[u] = sm = 0;
  dfs(u);
  if (sm < Ans) Ans = sm, an = u;
}
void dfss(int u) {
  bo[u] = 1;
  sm += a[u] * sqrt(d[u]);
  for (pair<int, int> W : Ed[u]) {
    int v = W.first;
    if (!bo[v]) {
      d[v] = d[u] + W.second;
      dfs(v);
    }
  }
  bo[u] = 0;
}
inline double calc(int v) {
  d[v] = sm = 0;
  dfss(v);
  return sm;
}
void dc(int u) {
  bo[u = grt(u)] = 1;
  gao(u);
  int w = 0;
  double ma = -1e10;
  for (pair<int, int> W : Ed[u]) {
    int v = W.first;
    if (!bo[v]) {
      double jb = calc(v);
      if (jb > ma) ma = jb, w = v;
    }
  }
  if (w) dc(w);
}
int main() {
  n = IN();
  for (int _r = n, i = 1; i <= _r; ++i) a[i] = IN();
  for (int _r = n, i = 1; i < _r; ++i) {
    int u = IN(), v = IN(), w = IN();
    Ed[u].push_back({v, w});
    Ed[v].push_back({u, w});
  }
  gsz(1);
  dc(1);
  printf("%d %.20lf\n", an, Ans);
}
