#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(0);
  int n;
  cin.tie(0), cout.tie(0);
  cin >> n;
  vector<pair<int, int> > G[n + 2];
  for (int i = 1, u, v, w; i < n; i++) {
    cin >> u >> v >> w;
    G[u].push_back({v, w});
    G[v].push_back({u, w});
  }
  vector<long long> dp(n + 2, 0), sz(n + 2, 0);
  function<void(int, int)> dfs = [&](int u, int p) {
    sz[u] = 1;
    for (auto& v : G[u]) {
      if (v.first == p) continue;
      dp[v.first] += v.second;
      dfs(v.first, u);
      dp[u] += dp[v.first];
      sz[u] += sz[v.first];
    }
  };
  dfs(1, 0);
  long long sum = 0, clk = 0;
  function<void(int, int)> dfs1 = [&](int u, int p) {
    sum += clk;
    sort(G[u].begin(), G[u].end(), [&](pair<int, int> a, pair<int, int> b) {
      return dp[a.first] * sz[b.first] < dp[b.first] * sz[a.first];
    });
    for (auto& v : G[u]) {
      if (v.first == p) continue;
      clk += v.second;
      dfs1(v.first, u);
      clk += v.second;
    }
  };
  dfs1(1, 0);
  double res = (sum / (1.0 * (n - 1)));
  cout << fixed << setprecision(10) << res << "\n";
  return 0;
}
