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;
long long n, c[((long long)201 * 1000)], sz[((long long)201 * 1000)];
vector<pair<long long, long long> > e[((long long)201 * 1000)];
long double val[((long long)201 * 1000)], val_now, val_best;
long long best = -1;
bool mark[((long long)201 * 1000)];
void pre_dfs(long long x, long long par = 0) {
  sz[x] = 1;
  for (auto u : e[x]) {
    if (u.first == par || mark[u.first]) continue;
    pre_dfs(u.first, x);
    sz[x] += sz[u.first];
  }
}
long long search_roid(long long x, long long all, long long par = 0) {
  for (auto u : e[x]) {
    if (u.first == par || mark[u.first]) continue;
    if (sz[u.first] > all / 2) return search_roid(u.first, all, x);
  }
  return x;
}
void dfs(long long x, long long par, long long root, long long edge,
         long long dis = 0) {
  val_now += (long double)c[x] * (dis + edge) * sqrt((long double)dis + edge);
  val[root] += (long double)c[x] * (dis + edge) * sqrt((long double)dis + edge);
  for (auto u : e[x]) {
    if (u.first == par) continue;
    dfs(u.first, x, root, edge, dis + u.second);
  }
}
void solve(long long x) {
  val_now = 0;
  memset(val, 0, sizeof val);
  pre_dfs(x);
  long long v = search_roid(x, sz[x]), max_id = e[v][0].first;
  long double sum = 0;
  for (auto u : e[v]) {
    dfs(u.first, v, u.first, u.second);
    sum += val[u.first];
    if (val[max_id] < val[u.first]) max_id = u.first;
  }
  if (best == -1 || val_best > val_now) best = v, val_best = val_now;
  mark[v] = 1;
  if (sum - val[max_id] < val[max_id] && !mark[max_id]) solve(max_id);
  if (val_best < val_now) v = best, val_now = val_best;
  cout << v << " " << fixed << setprecision(16) << val_now << "\n";
  exit(0);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  if (n == 1) return cout << "1 0.000000000\n", 0;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 0; i < n - 1; i++) {
    long long v, u, w;
    cin >> v >> u >> w;
    e[v].push_back({u, w});
    e[u].push_back({v, w});
  }
  solve(1);
  return 0;
}
