#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e5 + 10;
int n;
vector<pair<int, int> > e[MAXN];
double E[MAXN];
int pre[MAXN], tot[MAXN];
double p[MAXN];
void dfs1(int u, int father) {
  pre[u] = 0;
  tot[u] = 1;
  for (int i = 0; i < (int)e[u].size(); i++) {
    int v = e[u][i].first, w = e[u][i].second;
    if (v == father) continue;
    dfs1(v, u);
    pre[u] += 2 * w;
    pre[u] += pre[v];
    tot[u] += tot[v];
  }
}
bool cmp(const int &a1, const int &a2) {
  return (double)p[a2] * pre[a1] < (double)p[a1] * pre[a2];
}
void dfs2(int u, int father) {
  E[u] = 0.0;
  vector<int> List;
  for (int i = 0; i < (int)e[u].size(); i++) {
    int v = e[u][i].first, w = e[u][i].second;
    if (v == father) continue;
    dfs2(v, u);
    List.push_back(v);
    E[v] += w;
    pre[v] += 2 * w;
  }
  for (int i = 0; i < (int)List.size(); i++)
    p[List[i]] = tot[List[i]] / (double)tot[u];
  sort(List.begin(), List.end(), cmp);
  double prefix = 1.0 - 1.0 / (double)tot[u];
  for (int i = 0; i < (int)List.size(); i++) {
    int now = List[i];
    E[u] += p[now] * E[now] + (prefix - p[now]) * pre[now];
    prefix -= p[now];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y, w;
    scanf("%d%d%d", &x, &y, &w);
    e[x].push_back(make_pair(y, w));
    e[y].push_back(make_pair(x, w));
  }
  dfs1(1, -1);
  dfs2(1, -1);
  printf("%.10f\n", E[1] * n / (n - 1));
  return 0;
}
