#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const long long mod = 1e9 + 7;
int n;
struct mmp {
  long double s;
  int to, cc;
  bool operator<(const mmp &op) const { return s < op.s; }
} gg;
vector<mmp> v[maxn];
long long s[maxn], ans, p[maxn];
void dfs1(int x, int y) {
  p[x] = 1;
  if (v[x].size() == 1 && y != 0) return;
  for (int i = 0; i < v[x].size(); i++) {
    int to = v[x][i].to, cc = v[x][i].cc;
    if (to != y) {
      dfs1(to, x);
      s[to] += cc;
      s[x] += s[to];
      p[x] += p[to];
      v[x][i].s = (long double)s[to] / (long double)p[to];
    }
  }
  sort(v[x].begin(), v[x].end());
}
int dfs2(int x, int y, int p) {
  ans += p;
  if (v[x].size() == 1 && y != 0) return p;
  for (int i = 0; i < v[x].size(); i++) {
    int to = v[x][i].to, cc = v[x][i].cc;
    if (to != y) {
      p += cc;
      p = dfs2(to, x, p);
      p += cc;
    }
  }
  return p;
}
int main() {
  int i, j, x, y, z;
  cin >> n;
  for (i = 1; i < n; i++) {
    scanf("%d%d%d", &x, &y, &z);
    gg.cc = z;
    gg.to = y;
    v[x].push_back(gg);
    gg.to = x;
    v[y].push_back(gg);
  }
  dfs1(1, 0);
  dfs2(1, 0, 0);
  long double sum = ans, div = n - 1;
  printf("%.10Lf\n", sum / div);
  return 0;
}
