#include <bits/stdc++.h>
using namespace std;
inline int gi() {
  register int data = 0, w = 1;
  register char ch = 0;
  while (ch != '-' && (ch > '9' || ch < '0')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
  return w * data;
}
double v[500005], ans;
int N, size[500005];
struct Edge {
  int to, cost;
};
bool cmp(const Edge &lhs, const Edge &rhs) {
  return v[lhs.to] * size[rhs.to] < v[rhs.to] * size[lhs.to];
}
vector<Edge> G[500005];
void Add_Edge(int u, int v, int w) { G[u].push_back((Edge){v, w}); }
double dfs1(int x, int f) {
  size[x] = 1;
  for (int i = 0; i < G[x].size(); i++) {
    Edge e = G[x][i];
    if (e.to == f) {
      v[x] += 2 * e.cost;
      continue;
    } else {
      v[x] += dfs1(e.to, x);
      size[x] += size[e.to];
    }
  }
  return v[x];
}
double dfs2(int x, double t, int f) {
  ans += t;
  double tt = t;
  for (int i = 0; i < G[x].size(); i++) {
    Edge e = G[x][i];
    if (e.to == f) continue;
    t = dfs2(e.to, tt + e.cost, x) + e.cost;
    tt = t;
  }
  return t;
}
int main() {
  N = gi();
  if (N == 1) return puts("0") & 0;
  for (int i = 1; i < N; i++) {
    int u = gi(), v = gi(), w = gi();
    Add_Edge(u, v, w);
    Add_Edge(v, u, w);
  }
  dfs1(1, 0);
  for (int i = 1; i <= N; i++) sort(G[i].begin(), G[i].end(), cmp);
  dfs2(1, 0, 0);
  printf("%0.10lf\n", ans / (N - 1));
  return 0;
}
