#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const long long inf = numeric_limits<long long>::max() / 10;
double T[maxn], C[maxn], dp[maxn];
vector<int> e[maxn], w[maxn];
void dfs(int u, int par, int eCost) {
  int v, wt, k = 0;
  T[u] = eCost * 2;
  C[u] = 1;
  vector<int> nxt;
  for (int i = 0; i < e[u].size(); ++i) {
    v = e[u][i];
    if (v != par) {
      wt = w[u][i];
      dfs(v, u, wt);
      k++;
      T[u] += T[v];
      C[u] += C[v];
      nxt.emplace_back(v);
    }
  }
  sort((nxt).begin(), (nxt).end(),
       [](int x, int y) { return T[x] * C[y] < T[y] * C[x]; });
  double cur = 0, cnt = 0;
  for (auto v : nxt) {
    cur += dp[v] + C[v] * cnt;
    cnt += T[v];
  }
  dp[u] = cur + C[u] * eCost;
}
int main() {
  int n, x, y, z;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d %d %d", &x, &y, &z);
    e[x].emplace_back(y);
    e[y].emplace_back(x);
    w[x].emplace_back(z);
    w[y].emplace_back(z);
  }
  dfs(1, 0, 0);
  double res = dp[1] / (n - 1);
  printf("%0.7lf", res);
  return 0;
}
