#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 100100;
const long long INF = 1e10;
vector<pair<long long, long long> > V[MAXN];
long long N, a, b, w;
long long cost[MAXN];
long long entry[MAXN];
long long sub[MAXN];
vector<pair<long long, long long> > X;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first * b.second < b.first * a.second;
}
void dfs(int x, int p) {
  sub[x] = 1;
  if (x != 1 && (long long)V[x].size() == 1) {
    cost[x] = entry[x] = 0;
    return;
  }
  long long totcost = 0;
  for (auto v : V[x])
    if (v.first != p) {
      dfs(v.first, x);
      sub[x] += sub[v.first];
      totcost += cost[v.first] + v.second * sub[v.first];
      entry[x] = entry[x] + v.second * 2 + entry[v.first];
    }
  X.clear();
  for (auto v : V[x])
    if (v.first != p) {
      X.emplace_back(make_pair(entry[v.first] + v.second * 2, sub[v.first]));
    }
  sort(X.begin(), X.end(), cmp);
  long long run = 0;
  for (auto v : X) {
    totcost += v.second * run;
    run += v.first;
  }
  cost[x] = totcost;
}
int main() {
  cin >> N;
  for (int i = 1; i < N; ++i) {
    cin >> a >> b >> w;
    V[a].emplace_back(b, w);
    V[b].emplace_back(a, w);
  }
  dfs(1, -1);
  printf("%.9lf", (double)cost[1] / (N - 1));
}
