#include <bits/stdc++.h>
using namespace std;
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int n, subsum[100005], cnt[100005];
vector<pair<int, int> > adj[100005];
double DP[100005];
void dfs0(int v, int par) {
  subsum[v] = 0;
  cnt[v] = 1;
  for (auto it : adj[v]) {
    if (it.first == par) continue;
    dfs0(it.first, v);
    subsum[v] += subsum[it.first] + it.second;
    cnt[v] += cnt[it.first];
  }
}
bool comp(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  return 1LL * a.second.first * b.second.second <
         1LL * b.second.first * a.second.second;
}
void dfs(int v, int par) {
  vector<pair<int, pair<int, int> > > children;
  for (auto it : adj[v]) {
    if (it.first == par) continue;
    dfs(it.first, v);
    children.push_back(
        {it.first, {subsum[it.first] + it.second, cnt[it.first]}});
    DP[v] += DP[it.first];
  }
  sort(children.begin(), children.end(), comp);
  int sum = 0;
  for (auto it : children) {
    int vv = it.first;
    DP[v] += (1.0 * cnt[vv] / (n - 1)) * (sum + (it.second.first - subsum[vv]));
    sum += 2 * it.second.first;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  int e = n - 1;
  while (e--) {
    int a, b, c;
    cin >> a >> b >> c;
    adj[a].push_back({b, c});
    adj[b].push_back({a, c});
  }
  dfs0(1, -1);
  dfs(1, -1);
  cout << fixed << setprecision(7) << DP[1];
  return 0;
}
