#include <bits/stdc++.h>
using namespace std;
bool vis[100004];
struct data {
  double st, size, sum;
  data() : size(0), st(0), sum(0) {}
} node[100004];
vector<int> adj[100004];
vector<double> con[100004];
bool operator<(const data &a, const data &b) {
  return (a.sum / a.size) < (b.sum / b.size);
}
void dfs(int u) {
  vis[u] = true;
  double st = node[u].st, size(0);
  node[u].sum = st;
  node[u].size = 1;
  vector<data> tmp;
  tmp.clear();
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (vis[v]) continue;
    node[v].st = con[u][i];
    dfs(v);
    node[u].sum += node[v].sum;
    size += node[v].size;
    tmp.push_back(node[v]);
  }
  node[u].size += size;
  node[u].st += (st * size);
  sort(tmp.begin(), tmp.end());
  for (int i = 0; i < tmp.size(); i++) {
    data d = tmp[i];
    size -= d.size;
    st = d.st;
    node[u].st += d.st;
    node[u].st += 2 * d.sum * size;
  }
}
int main() {
  int n, i;
  int a, b;
  double t;
  memset(vis, 0, sizeof vis);
  for (i = 0; i < 100004; i++) {
    adj[i].clear();
    con[i].clear();
  }
  for (i = 1, scanf("%d", &n); i < n; i++) {
    scanf("%d%d%lf", &a, &b, &t);
    adj[a].push_back(b);
    con[a].push_back(t);
    adj[b].push_back(a);
    con[b].push_back(t);
  }
  dfs(1);
  printf("%.10lf", node[1].st / double(n - 1));
  return 0;
}
