#include <bits/stdc++.h>
#pragma comment(linker, �� / STACK : 1024000000, 1024000000��)
using namespace std;
struct EDGE {
  long long to, last;
  long double t;
} e[2 * 100007];
long double T[100007], f[100007], Num[100007];
long long Last[100007];
long long tot, n, fa[100007], head[100007], q[100007];
void Addline(long long u, long long v, long long t) {
  e[++tot].last = head[u];
  e[tot].to = v;
  e[tot].t = t;
  head[u] = tot;
}
bool cmp(long long x, long long y) { return T[x] / Num[x] < T[y] / Num[y]; }
void dfs(long long u) {
  Num[u] = 1;
  for (long long i = head[u]; i; i = e[i].last) {
    long long v = e[i].to;
    if (v == fa[u]) continue;
    fa[v] = u;
    T[v] += e[i].t;
    Last[v] = i;
    dfs(v);
    Num[u] += Num[v];
    T[u] += T[v];
  }
  q[0] = 0;
  for (long long i = head[u]; i; i = e[i].last) {
    long long v = e[i].to;
    if (v == fa[u]) continue;
    q[++q[0]] = v;
  }
  long double Tot = Num[u] - 1;
  sort(q + 1, q + q[0] + 1, cmp);
  for (long long i = 1; i <= q[0]; ++i) {
    Tot -= Num[q[i]];
    f[u] += T[q[i]] * 2 * Tot + e[Last[q[i]]].t * Num[q[i]] + f[q[i]];
  }
}
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (long long i = 1; i < n; ++i) {
    long long u, v, t;
    cin >> u >> v >> t;
    Addline(u, v, t), Addline(v, u, t);
  }
  dfs(1);
  cout.precision(16);
  long double ANS = f[1], FM = n - 1;
  cout << ANS / FM;
  return 0;
}
