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;
void SR(int &x) { scanf("%d", &x); }
void SR(long long &x) { scanf("%lld", &x); }
void SR(double &x) { scanf("%lf", &x); }
void SR(char *s) { scanf("%s", s); }
void RI() {}
template <typename I, typename... T>
void RI(I &x, T &...tail) {
  SR(x);
  RI(tail...);
}
const int maxn = 4e5 + 5;
int n, on;
struct Edge {
  Edge() {}
  Edge(int t, int w) : tar(t), wei(w) {}
  int tar, wei;
};
vector<Edge> edge;
vector<int> id[maxn];
int w[maxn];
void add(int a, int b, int c) {
  id[a].push_back(((int)(edge).size()));
  edge.push_back(Edge(b, c));
}
void read() {
  RI(n);
  on = n;
  for (int i = (1); i <= int(n); i++) RI(w[i]);
  for (int i = 0; i < int(n - 1); i++) {
    int a, b, c;
    RI(a, b, c);
    add(a, b, c);
    add(b, a, c);
  }
}
void build() {
  for (int i = (1); i <= int(n); i++)
    if (((int)(id[i]).size()) > 3) {
      n++;
      for (int j = (2); j <= int(((int)(id[i]).size()) - 1); j++) {
        int x = id[i][j];
        id[n].push_back(x);
        assert(edge[x ^ 1].tar == i);
        edge[x ^ 1].tar = n;
      }
      id[i].resize(2);
      add(i, n, 0);
      add(n, i, 0);
    }
}
bitset<maxn> del;
int siz[maxn], par[maxn];
int dfs1(int u, int p, vector<int> &node) {
  siz[u] = 1;
  par[u] = p;
  node.push_back(u);
  for (auto x : id[u]) {
    int v = edge[x].tar;
    if (v != p && !del[v]) siz[u] += dfs1(v, u, node);
  }
  return siz[u];
}
int dis[maxn];
void dfs2(int u, int p, int d) {
  dis[u] = d;
  for (auto x : id[u]) {
    int v = edge[x].tar;
    if (v != p) dfs2(v, u, d + edge[x].wei);
  }
}
long double calc(int u) {
  dfs2(u, 0, 0);
  long double ans = 0;
  for (int i = (1); i <= int(n); i++)
    ans += dis[i] * sqrt((long double)dis[i]) * w[i];
  return ans;
}
int dfs3(int u, int p) {
  if (u <= on) return u;
  int ret = 0;
  for (auto x : id[u]) {
    int v = edge[x].tar;
    if (v != p && edge[x].wei == 0) ret += dfs3(v, u);
  }
  return ret;
}
void sol() {
  int cur = 1;
  pair<int, long double> ans;
  while (1) {
    vector<int> node;
    dfs1(cur, 0, node);
    int mid = cur, lo = 1 << 30;
    for (auto u : node) {
      int my = siz[cur] - siz[u];
      for (auto x : id[u]) {
        int v = edge[x].tar;
        if (v != par[u] && !del[v]) my = max(my, siz[v]);
      }
      if (my < lo) lo = my, mid = u;
    }
    long double myans = calc(mid);
    if (((int)(node).size()) == 1) {
      ans = make_pair(mid, myans);
      break;
    }
    map<int, long double> kid;
    for (auto x : id[mid]) {
      int v = edge[x].tar;
      if (!del[v]) kid[v] = calc(v);
    }
    auto midans = make_pair(mid, myans);
    for (auto p : kid)
      if (p.second <= midans.second) midans = p;
    if (midans.first == mid) {
      ans = midans;
      break;
    }
    del[mid] = 1;
    cur = midans.first;
  }
  printf("%d ", dfs3(ans.first, 0));
  cout << setprecision(18) << ans.second << endl;
}
int main() {
  read();
  build();
  sol();
  return 0;
}
