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 MAXN = 200000;
long double eps = 0.0000001;
vector<vector<pair<int, int>>> g(MAXN);
vector<bool> used1(MAXN), used2(MAXN);
vector<long double> d(MAXN), w;
vector<vector<long double>> dd(2);
long double koren(long double puk) {
  long double l = 0, r = 1e18;
  for (int i = 0; i < 100; i++) {
    long double m = (l + r) / 2;
    if (m * m < puk) {
      l = m;
    } else {
      r = m;
    }
  }
  return l;
}
void read(vector<long double> &a) {
  for (int i = 0; i < a.size(); i++) {
    cin >> a[i];
  }
}
void write(vector<int> &a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] << ' ';
  }
  cout << endl;
}
int dfs1(int v) {
  used2[v] = true;
  d[v] = 1;
  int ans = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    if (!used1[to] && !used2[to]) {
      ans += dfs1(to);
      d[v] += d[to];
    }
  }
  return ans;
}
int dfs2(int v, int p, int m) {
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    if (to != p && !used1[to]) {
      if (d[to] > m / 2) {
        return dfs2(to, v, m);
      }
    }
  }
  return v;
}
long double dfs3(int v, int len, int p) {
  long double ans = (long double)w[v] * sqrt(len);
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    int we = g[v][i].second;
    if (p != to) {
      ans += dfs3(to, len + we, v);
    }
  }
  return ans;
}
long double dfs4(int v, long double len, int p) {
  long double ans = w[v] * len * koren(len);
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    long double we = g[v][i].second;
    if (to != p) {
      ans += dfs4(to, len + we, v);
    }
  }
  return ans;
}
long double f(int v) { return dfs4(v, 0, -1); }
void dfsio(int v, long double len, int p, int t) {
  dd[t][v] = len;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    long double we = g[v][i].second;
    if (p != to) {
      dfsio(to, len + we, v, t);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(30);
  int n;
  cin >> n;
  w.resize(n);
  read(w);
  for (int i = 0; i < n - 1; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    g[x].push_back({y, z});
    g[y].push_back({x, z});
  }
  int pt = 0;
  vector<int> seq;
  for (int t = 0; t < 27; t++) {
    used2.assign(MAXN, false);
    if (!used1[pt] && !used2[pt]) {
      int m = dfs1(pt);
      int v = dfs2(pt, -1, m);
      used1[v] = true;
      seq.push_back(v);
      vector<pair<long double, int>> der;
      long double ttl = 0;
      for (int i = 0; i < g[v].size(); i++) {
        int to = g[v][i].first;
        int we = g[v][i].second;
        long double dir = dfs3(to, we, -1);
        der.push_back({dir, to});
        ttl += dir;
      }
      bool sdv = false;
      for (int i = 0; i < der.size(); i++) {
        if (ttl - 2 * der[i].first < 0 && !used1[der[i].second]) {
          sdv = true;
          pt = der[i].second;
        }
      }
      if (!sdv) {
        if (seq.size() == 1) {
          cout << seq[0] + 1 << ' ' << f(seq[0]);
        } else {
          int v = seq[seq.size() - 1], u = seq[seq.size() - 2];
          dd[0].resize(n);
          dd[1].resize(n);
          dfsio(v, 0, -1, 0);
          dfsio(u, 0, -1, 1);
          long double kek = 0;
          for (int i = 0; i < n; i++) {
            kek += w[i] *
                   (dd[0][i] * koren(dd[0][i]) - dd[1][i] * koren(dd[1][i]));
          }
          if (f(v) < f(u)) {
            cout << v + 1 << ' ' << f(v);
          } else {
            cout << u + 1 << ' ' << f(u);
          }
        }
        return 0;
      }
    }
  }
}
