#include <bits/stdc++.h>
using namespace std;
int n;
vector<long long> p, t, w, upc;
vector<vector<pair<int, int> > > g;
bool cmp(int u, int v) {
  return w[v] * (t[u] + 2 * upc[u]) < w[u] * (t[v] + 2 * upc[v]);
}
void dfs(int u, int pr) {
  w[u] = 1;
  vector<int> anc;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first, c = g[u][i].second;
    if (v == pr) continue;
    upc[v] = c;
    dfs(v, u);
    w[u] += w[v];
    t[u] += 2 * c + t[v];
    anc.push_back(v);
  }
  sort(anc.begin(), anc.end(), cmp);
  long long cur = 0;
  for (int i = 0; i < anc.size(); i++) {
    int v = anc[i];
    p[u] += p[v] + (cur + upc[v]) * w[v];
    cur += t[v] + 2 * upc[v];
  }
}
int main() {
  cin >> n;
  g.resize(n);
  for (int i = 0; i + 1 < n; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    u--, v--;
    g[u].push_back(make_pair(v, c));
    g[v].push_back(make_pair(u, c));
  }
  p.resize(n);
  t.resize(n);
  w.resize(n);
  upc.resize(n);
  dfs(0, -1);
  cout << fixed << setprecision(9) << p[0] / (double)(n - 1) << '\n';
  return 0;
}
