#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e5 + 5;
double dp[Maxn];
int First[Maxn], Next[Maxn * 2], to[Maxn * 2], cnt, WE[Maxn * 2], size[Maxn],
    nmsl[Maxn];
inline void add(int z, int y, int w) {
  Next[++cnt] = First[z];
  First[z] = cnt;
  to[cnt] = y;
  WE[cnt] = w;
}
inline int R() {
  char c;
  int res, sign = 1;
  while ((c = getchar()) > '9' || c < '0')
    if (c == '-') sign = -1;
  res = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0';
  return res * sign;
}
int n, m, O;
void dfs(int pos, int father) {
  priority_queue<pair<double, int>, vector<pair<double, int> >,
                 greater<pair<double, int> > >
      q;
  double res = 0, S = 0, z = 0;
  for (int k = First[pos]; k; k = Next[k]) {
    if (to[k] == father) continue;
    dfs(to[k], pos);
    q.push(make_pair((nmsl[to[k]] + WE[k]) * (double)(size[pos]) / size[to[k]],
                     k));
  }
  double rs = 1.0;
  if (pos != 1) rs = (double)(size[pos] - 1) / size[pos];
  while (!q.empty()) {
    int x = q.top().second;
    q.pop();
    res += (dp[to[x]] + WE[x] + S) * (double)size[to[x]] / (size[pos]);
    S += (nmsl[to[x]] + WE[x]) * 2;
  }
  dp[pos] = res;
}
void deal(int pos, int father) {
  size[pos] = 1;
  for (int k = First[pos]; k; k = Next[k]) {
    if (to[k] == father) continue;
    deal(to[k], pos);
    nmsl[pos] += WE[k] + nmsl[to[k]];
    size[pos] += size[to[k]];
  }
}
int main() {
  n = R();
  int x, y, w;
  for (int i = 1; i < n; i++) {
    x = R();
    y = R();
    w = R();
    add(x, y, w);
    add(y, x, w);
  }
  deal(1, 0);
  size[1]--;
  dfs(1, 0);
  printf("%.9lf\n", dp[1]);
  return 0;
}
